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 InputSecureValue struct {
Flags bin .Fields
Type SecureValueTypeClass
Data SecureData
FrontSide InputSecureFileClass
ReverseSide InputSecureFileClass
Selfie InputSecureFileClass
Translation []InputSecureFileClass
Files []InputSecureFileClass
PlainData SecurePlainDataClass
}
const InputSecureValueTypeID = 0xdb21d0a7
var (
_ bin .Encoder = &InputSecureValue {}
_ bin .Decoder = &InputSecureValue {}
_ bin .BareEncoder = &InputSecureValue {}
_ bin .BareDecoder = &InputSecureValue {}
)
func (i *InputSecureValue ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Type == nil ) {
return false
}
if !(i .Data .Zero ()) {
return false
}
if !(i .FrontSide == nil ) {
return false
}
if !(i .ReverseSide == nil ) {
return false
}
if !(i .Selfie == nil ) {
return false
}
if !(i .Translation == nil ) {
return false
}
if !(i .Files == nil ) {
return false
}
if !(i .PlainData == nil ) {
return false
}
return true
}
func (i *InputSecureValue ) String () string {
if i == nil {
return "InputSecureValue(nil)"
}
type Alias InputSecureValue
return fmt .Sprintf ("InputSecureValue%+v" , Alias (*i ))
}
func (i *InputSecureValue ) FillFrom (from interface {
GetType () (value SecureValueTypeClass )
GetData () (value SecureData , ok bool )
GetFrontSide () (value InputSecureFileClass , ok bool )
GetReverseSide () (value InputSecureFileClass , ok bool )
GetSelfie () (value InputSecureFileClass , ok bool )
GetTranslation () (value []InputSecureFileClass , ok bool )
GetFiles () (value []InputSecureFileClass , ok bool )
GetPlainData () (value SecurePlainDataClass , ok bool )
}) {
i .Type = from .GetType ()
if val , ok := from .GetData (); ok {
i .Data = val
}
if val , ok := from .GetFrontSide (); ok {
i .FrontSide = val
}
if val , ok := from .GetReverseSide (); ok {
i .ReverseSide = val
}
if val , ok := from .GetSelfie (); ok {
i .Selfie = val
}
if val , ok := from .GetTranslation (); ok {
i .Translation = val
}
if val , ok := from .GetFiles (); ok {
i .Files = val
}
if val , ok := from .GetPlainData (); ok {
i .PlainData = val
}
}
func (*InputSecureValue ) TypeID () uint32 {
return InputSecureValueTypeID
}
func (*InputSecureValue ) TypeName () string {
return "inputSecureValue"
}
func (i *InputSecureValue ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputSecureValue" ,
ID : InputSecureValueTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "Data" ,
SchemaName : "data" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "FrontSide" ,
SchemaName : "front_side" ,
Null : !i .Flags .Has (1 ),
},
{
Name : "ReverseSide" ,
SchemaName : "reverse_side" ,
Null : !i .Flags .Has (2 ),
},
{
Name : "Selfie" ,
SchemaName : "selfie" ,
Null : !i .Flags .Has (3 ),
},
{
Name : "Translation" ,
SchemaName : "translation" ,
Null : !i .Flags .Has (6 ),
},
{
Name : "Files" ,
SchemaName : "files" ,
Null : !i .Flags .Has (4 ),
},
{
Name : "PlainData" ,
SchemaName : "plain_data" ,
Null : !i .Flags .Has (5 ),
},
}
return typ
}
func (i *InputSecureValue ) SetFlags () {
if !(i .Data .Zero ()) {
i .Flags .Set (0 )
}
if !(i .FrontSide == nil ) {
i .Flags .Set (1 )
}
if !(i .ReverseSide == nil ) {
i .Flags .Set (2 )
}
if !(i .Selfie == nil ) {
i .Flags .Set (3 )
}
if !(i .Translation == nil ) {
i .Flags .Set (6 )
}
if !(i .Files == nil ) {
i .Flags .Set (4 )
}
if !(i .PlainData == nil ) {
i .Flags .Set (5 )
}
}
func (i *InputSecureValue ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputSecureValue#db21d0a7 as nil" )
}
b .PutID (InputSecureValueTypeID )
return i .EncodeBare (b )
}
func (i *InputSecureValue ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputSecureValue#db21d0a7 as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field flags: %w" , err )
}
if i .Type == nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field type is nil" )
}
if err := i .Type .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field type: %w" , err )
}
if i .Flags .Has (0 ) {
if err := i .Data .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field data: %w" , err )
}
}
if i .Flags .Has (1 ) {
if i .FrontSide == nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field front_side is nil" )
}
if err := i .FrontSide .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field front_side: %w" , err )
}
}
if i .Flags .Has (2 ) {
if i .ReverseSide == nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field reverse_side is nil" )
}
if err := i .ReverseSide .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field reverse_side: %w" , err )
}
}
if i .Flags .Has (3 ) {
if i .Selfie == nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field selfie is nil" )
}
if err := i .Selfie .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field selfie: %w" , err )
}
}
if i .Flags .Has (6 ) {
b .PutVectorHeader (len (i .Translation ))
for idx , v := range i .Translation {
if v == nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field translation element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field translation element with index %d: %w" , idx , err )
}
}
}
if i .Flags .Has (4 ) {
b .PutVectorHeader (len (i .Files ))
for idx , v := range i .Files {
if v == nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field files element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field files element with index %d: %w" , idx , err )
}
}
}
if i .Flags .Has (5 ) {
if i .PlainData == nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field plain_data is nil" )
}
if err := i .PlainData .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSecureValue#db21d0a7: field plain_data: %w" , err )
}
}
return nil
}
func (i *InputSecureValue ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputSecureValue#db21d0a7 to nil" )
}
if err := b .ConsumeID (InputSecureValueTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputSecureValue ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputSecureValue#db21d0a7 to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field flags: %w" , err )
}
}
{
value , err := DecodeSecureValueType (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field type: %w" , err )
}
i .Type = value
}
if i .Flags .Has (0 ) {
if err := i .Data .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field data: %w" , err )
}
}
if i .Flags .Has (1 ) {
value , err := DecodeInputSecureFile (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field front_side: %w" , err )
}
i .FrontSide = value
}
if i .Flags .Has (2 ) {
value , err := DecodeInputSecureFile (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field reverse_side: %w" , err )
}
i .ReverseSide = value
}
if i .Flags .Has (3 ) {
value , err := DecodeInputSecureFile (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field selfie: %w" , err )
}
i .Selfie = value
}
if i .Flags .Has (6 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field translation: %w" , err )
}
if headerLen > 0 {
i .Translation = make ([]InputSecureFileClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputSecureFile (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field translation: %w" , err )
}
i .Translation = append (i .Translation , value )
}
}
if i .Flags .Has (4 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field files: %w" , err )
}
if headerLen > 0 {
i .Files = make ([]InputSecureFileClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputSecureFile (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field files: %w" , err )
}
i .Files = append (i .Files , value )
}
}
if i .Flags .Has (5 ) {
value , err := DecodeSecurePlainData (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSecureValue#db21d0a7: field plain_data: %w" , err )
}
i .PlainData = value
}
return nil
}
func (i *InputSecureValue ) GetType () (value SecureValueTypeClass ) {
if i == nil {
return
}
return i .Type
}
func (i *InputSecureValue ) SetData (value SecureData ) {
i .Flags .Set (0 )
i .Data = value
}
func (i *InputSecureValue ) GetData () (value SecureData , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .Data , true
}
func (i *InputSecureValue ) SetFrontSide (value InputSecureFileClass ) {
i .Flags .Set (1 )
i .FrontSide = value
}
func (i *InputSecureValue ) GetFrontSide () (value InputSecureFileClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .FrontSide , true
}
func (i *InputSecureValue ) SetReverseSide (value InputSecureFileClass ) {
i .Flags .Set (2 )
i .ReverseSide = value
}
func (i *InputSecureValue ) GetReverseSide () (value InputSecureFileClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (2 ) {
return value , false
}
return i .ReverseSide , true
}
func (i *InputSecureValue ) SetSelfie (value InputSecureFileClass ) {
i .Flags .Set (3 )
i .Selfie = value
}
func (i *InputSecureValue ) GetSelfie () (value InputSecureFileClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (3 ) {
return value , false
}
return i .Selfie , true
}
func (i *InputSecureValue ) SetTranslation (value []InputSecureFileClass ) {
i .Flags .Set (6 )
i .Translation = value
}
func (i *InputSecureValue ) GetTranslation () (value []InputSecureFileClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (6 ) {
return value , false
}
return i .Translation , true
}
func (i *InputSecureValue ) SetFiles (value []InputSecureFileClass ) {
i .Flags .Set (4 )
i .Files = value
}
func (i *InputSecureValue ) GetFiles () (value []InputSecureFileClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (4 ) {
return value , false
}
return i .Files , true
}
func (i *InputSecureValue ) SetPlainData (value SecurePlainDataClass ) {
i .Flags .Set (5 )
i .PlainData = value
}
func (i *InputSecureValue ) GetPlainData () (value SecurePlainDataClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (5 ) {
return value , false
}
return i .PlainData , true
}
func (i *InputSecureValue ) MapTranslation () (value InputSecureFileClassArray , ok bool ) {
if !i .Flags .Has (6 ) {
return value , false
}
return InputSecureFileClassArray (i .Translation ), true
}
func (i *InputSecureValue ) MapFiles () (value InputSecureFileClassArray , ok bool ) {
if !i .Flags .Has (4 ) {
return value , false
}
return InputSecureFileClassArray (i .Files ), true
}
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 .