package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type SecureData struct {
Data []byte
DataHash []byte
Secret []byte
}
const SecureDataTypeID = 0x8aeabec3
var (
_ bin .Encoder = &SecureData {}
_ bin .Decoder = &SecureData {}
_ bin .BareEncoder = &SecureData {}
_ bin .BareDecoder = &SecureData {}
)
func (s *SecureData ) Zero () bool {
if s == nil {
return true
}
if !(s .Data == nil ) {
return false
}
if !(s .DataHash == nil ) {
return false
}
if !(s .Secret == nil ) {
return false
}
return true
}
func (s *SecureData ) String () string {
if s == nil {
return "SecureData(nil)"
}
type Alias SecureData
return fmt .Sprintf ("SecureData%+v" , Alias (*s ))
}
func (s *SecureData ) FillFrom (from interface {
GetData () (value []byte )
GetDataHash () (value []byte )
GetSecret () (value []byte )
}) {
s .Data = from .GetData ()
s .DataHash = from .GetDataHash ()
s .Secret = from .GetSecret ()
}
func (*SecureData ) TypeID () uint32 {
return SecureDataTypeID
}
func (*SecureData ) TypeName () string {
return "secureData"
}
func (s *SecureData ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "secureData" ,
ID : SecureDataTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Data" ,
SchemaName : "data" ,
},
{
Name : "DataHash" ,
SchemaName : "data_hash" ,
},
{
Name : "Secret" ,
SchemaName : "secret" ,
},
}
return typ
}
func (s *SecureData ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureData#8aeabec3 as nil" )
}
b .PutID (SecureDataTypeID )
return s .EncodeBare (b )
}
func (s *SecureData ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureData#8aeabec3 as nil" )
}
b .PutBytes (s .Data )
b .PutBytes (s .DataHash )
b .PutBytes (s .Secret )
return nil
}
func (s *SecureData ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureData#8aeabec3 to nil" )
}
if err := b .ConsumeID (SecureDataTypeID ); err != nil {
return fmt .Errorf ("unable to decode secureData#8aeabec3: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SecureData ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureData#8aeabec3 to nil" )
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode secureData#8aeabec3: field data: %w" , err )
}
s .Data = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode secureData#8aeabec3: field data_hash: %w" , err )
}
s .DataHash = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode secureData#8aeabec3: field secret: %w" , err )
}
s .Secret = value
}
return nil
}
func (s *SecureData ) GetData () (value []byte ) {
if s == nil {
return
}
return s .Data
}
func (s *SecureData ) GetDataHash () (value []byte ) {
if s == nil {
return
}
return s .DataHash
}
func (s *SecureData ) GetSecret () (value []byte ) {
if s == nil {
return
}
return s .Secret
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .