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 SecureRequiredType struct {
Flags bin .Fields
NativeNames bool
SelfieRequired bool
TranslationRequired bool
Type SecureValueTypeClass
}
const SecureRequiredTypeTypeID = 0x829d99da
func (s SecureRequiredType ) construct () SecureRequiredTypeClass { return &s }
var (
_ bin .Encoder = &SecureRequiredType {}
_ bin .Decoder = &SecureRequiredType {}
_ bin .BareEncoder = &SecureRequiredType {}
_ bin .BareDecoder = &SecureRequiredType {}
_ SecureRequiredTypeClass = &SecureRequiredType {}
)
func (s *SecureRequiredType ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .NativeNames == false ) {
return false
}
if !(s .SelfieRequired == false ) {
return false
}
if !(s .TranslationRequired == false ) {
return false
}
if !(s .Type == nil ) {
return false
}
return true
}
func (s *SecureRequiredType ) String () string {
if s == nil {
return "SecureRequiredType(nil)"
}
type Alias SecureRequiredType
return fmt .Sprintf ("SecureRequiredType%+v" , Alias (*s ))
}
func (s *SecureRequiredType ) FillFrom (from interface {
GetNativeNames () (value bool )
GetSelfieRequired () (value bool )
GetTranslationRequired () (value bool )
GetType () (value SecureValueTypeClass )
}) {
s .NativeNames = from .GetNativeNames ()
s .SelfieRequired = from .GetSelfieRequired ()
s .TranslationRequired = from .GetTranslationRequired ()
s .Type = from .GetType ()
}
func (*SecureRequiredType ) TypeID () uint32 {
return SecureRequiredTypeTypeID
}
func (*SecureRequiredType ) TypeName () string {
return "secureRequiredType"
}
func (s *SecureRequiredType ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "secureRequiredType" ,
ID : SecureRequiredTypeTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NativeNames" ,
SchemaName : "native_names" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "SelfieRequired" ,
SchemaName : "selfie_required" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "TranslationRequired" ,
SchemaName : "translation_required" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "Type" ,
SchemaName : "type" ,
},
}
return typ
}
func (s *SecureRequiredType ) SetFlags () {
if !(s .NativeNames == false ) {
s .Flags .Set (0 )
}
if !(s .SelfieRequired == false ) {
s .Flags .Set (1 )
}
if !(s .TranslationRequired == false ) {
s .Flags .Set (2 )
}
}
func (s *SecureRequiredType ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureRequiredType#829d99da as nil" )
}
b .PutID (SecureRequiredTypeTypeID )
return s .EncodeBare (b )
}
func (s *SecureRequiredType ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureRequiredType#829d99da as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode secureRequiredType#829d99da: field flags: %w" , err )
}
if s .Type == nil {
return fmt .Errorf ("unable to encode secureRequiredType#829d99da: field type is nil" )
}
if err := s .Type .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode secureRequiredType#829d99da: field type: %w" , err )
}
return nil
}
func (s *SecureRequiredType ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureRequiredType#829d99da to nil" )
}
if err := b .ConsumeID (SecureRequiredTypeTypeID ); err != nil {
return fmt .Errorf ("unable to decode secureRequiredType#829d99da: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SecureRequiredType ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureRequiredType#829d99da to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode secureRequiredType#829d99da: field flags: %w" , err )
}
}
s .NativeNames = s .Flags .Has (0 )
s .SelfieRequired = s .Flags .Has (1 )
s .TranslationRequired = s .Flags .Has (2 )
{
value , err := DecodeSecureValueType (b )
if err != nil {
return fmt .Errorf ("unable to decode secureRequiredType#829d99da: field type: %w" , err )
}
s .Type = value
}
return nil
}
func (s *SecureRequiredType ) SetNativeNames (value bool ) {
if value {
s .Flags .Set (0 )
s .NativeNames = true
} else {
s .Flags .Unset (0 )
s .NativeNames = false
}
}
func (s *SecureRequiredType ) GetNativeNames () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *SecureRequiredType ) SetSelfieRequired (value bool ) {
if value {
s .Flags .Set (1 )
s .SelfieRequired = true
} else {
s .Flags .Unset (1 )
s .SelfieRequired = false
}
}
func (s *SecureRequiredType ) GetSelfieRequired () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *SecureRequiredType ) SetTranslationRequired (value bool ) {
if value {
s .Flags .Set (2 )
s .TranslationRequired = true
} else {
s .Flags .Unset (2 )
s .TranslationRequired = false
}
}
func (s *SecureRequiredType ) GetTranslationRequired () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (2 )
}
func (s *SecureRequiredType ) GetType () (value SecureValueTypeClass ) {
if s == nil {
return
}
return s .Type
}
type SecureRequiredTypeOneOf struct {
Types []SecureRequiredTypeClass
}
const SecureRequiredTypeOneOfTypeID = 0x27477b4
func (s SecureRequiredTypeOneOf ) construct () SecureRequiredTypeClass { return &s }
var (
_ bin .Encoder = &SecureRequiredTypeOneOf {}
_ bin .Decoder = &SecureRequiredTypeOneOf {}
_ bin .BareEncoder = &SecureRequiredTypeOneOf {}
_ bin .BareDecoder = &SecureRequiredTypeOneOf {}
_ SecureRequiredTypeClass = &SecureRequiredTypeOneOf {}
)
func (s *SecureRequiredTypeOneOf ) Zero () bool {
if s == nil {
return true
}
if !(s .Types == nil ) {
return false
}
return true
}
func (s *SecureRequiredTypeOneOf ) String () string {
if s == nil {
return "SecureRequiredTypeOneOf(nil)"
}
type Alias SecureRequiredTypeOneOf
return fmt .Sprintf ("SecureRequiredTypeOneOf%+v" , Alias (*s ))
}
func (s *SecureRequiredTypeOneOf ) FillFrom (from interface {
GetTypes () (value []SecureRequiredTypeClass )
}) {
s .Types = from .GetTypes ()
}
func (*SecureRequiredTypeOneOf ) TypeID () uint32 {
return SecureRequiredTypeOneOfTypeID
}
func (*SecureRequiredTypeOneOf ) TypeName () string {
return "secureRequiredTypeOneOf"
}
func (s *SecureRequiredTypeOneOf ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "secureRequiredTypeOneOf" ,
ID : SecureRequiredTypeOneOfTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Types" ,
SchemaName : "types" ,
},
}
return typ
}
func (s *SecureRequiredTypeOneOf ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureRequiredTypeOneOf#27477b4 as nil" )
}
b .PutID (SecureRequiredTypeOneOfTypeID )
return s .EncodeBare (b )
}
func (s *SecureRequiredTypeOneOf ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureRequiredTypeOneOf#27477b4 as nil" )
}
b .PutVectorHeader (len (s .Types ))
for idx , v := range s .Types {
if v == nil {
return fmt .Errorf ("unable to encode secureRequiredTypeOneOf#27477b4: field types element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode secureRequiredTypeOneOf#27477b4: field types element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *SecureRequiredTypeOneOf ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureRequiredTypeOneOf#27477b4 to nil" )
}
if err := b .ConsumeID (SecureRequiredTypeOneOfTypeID ); err != nil {
return fmt .Errorf ("unable to decode secureRequiredTypeOneOf#27477b4: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SecureRequiredTypeOneOf ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureRequiredTypeOneOf#27477b4 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode secureRequiredTypeOneOf#27477b4: field types: %w" , err )
}
if headerLen > 0 {
s .Types = make ([]SecureRequiredTypeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeSecureRequiredType (b )
if err != nil {
return fmt .Errorf ("unable to decode secureRequiredTypeOneOf#27477b4: field types: %w" , err )
}
s .Types = append (s .Types , value )
}
}
return nil
}
func (s *SecureRequiredTypeOneOf ) GetTypes () (value []SecureRequiredTypeClass ) {
if s == nil {
return
}
return s .Types
}
func (s *SecureRequiredTypeOneOf ) MapTypes () (value SecureRequiredTypeClassArray ) {
return SecureRequiredTypeClassArray (s .Types )
}
const SecureRequiredTypeClassName = "SecureRequiredType"
type SecureRequiredTypeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () SecureRequiredTypeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeSecureRequiredType (buf *bin .Buffer ) (SecureRequiredTypeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case SecureRequiredTypeTypeID :
v := SecureRequiredType {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SecureRequiredTypeClass: %w" , err )
}
return &v , nil
case SecureRequiredTypeOneOfTypeID :
v := SecureRequiredTypeOneOf {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SecureRequiredTypeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode SecureRequiredTypeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type SecureRequiredTypeBox struct {
SecureRequiredType SecureRequiredTypeClass
}
func (b *SecureRequiredTypeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode SecureRequiredTypeBox to nil" )
}
v , err := DecodeSecureRequiredType (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .SecureRequiredType = v
return nil
}
func (b *SecureRequiredTypeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .SecureRequiredType == nil {
return fmt .Errorf ("unable to encode SecureRequiredTypeClass as nil" )
}
return b .SecureRequiredType .Encode (buf )
}
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 .