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 AccountWebBrowserSettingsNotModified struct {
}
const AccountWebBrowserSettingsNotModifiedTypeID = 0xc31c8f4e
func (w AccountWebBrowserSettingsNotModified ) construct () AccountWebBrowserSettingsClass { return &w }
var (
_ bin .Encoder = &AccountWebBrowserSettingsNotModified {}
_ bin .Decoder = &AccountWebBrowserSettingsNotModified {}
_ bin .BareEncoder = &AccountWebBrowserSettingsNotModified {}
_ bin .BareDecoder = &AccountWebBrowserSettingsNotModified {}
_ AccountWebBrowserSettingsClass = &AccountWebBrowserSettingsNotModified {}
)
func (w *AccountWebBrowserSettingsNotModified ) Zero () bool {
if w == nil {
return true
}
return true
}
func (w *AccountWebBrowserSettingsNotModified ) String () string {
if w == nil {
return "AccountWebBrowserSettingsNotModified(nil)"
}
type Alias AccountWebBrowserSettingsNotModified
return fmt .Sprintf ("AccountWebBrowserSettingsNotModified%+v" , Alias (*w ))
}
func (*AccountWebBrowserSettingsNotModified ) TypeID () uint32 {
return AccountWebBrowserSettingsNotModifiedTypeID
}
func (*AccountWebBrowserSettingsNotModified ) TypeName () string {
return "account.webBrowserSettingsNotModified"
}
func (w *AccountWebBrowserSettingsNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.webBrowserSettingsNotModified" ,
ID : AccountWebBrowserSettingsNotModifiedTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (w *AccountWebBrowserSettingsNotModified ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode account.webBrowserSettingsNotModified#c31c8f4e as nil" )
}
b .PutID (AccountWebBrowserSettingsNotModifiedTypeID )
return w .EncodeBare (b )
}
func (w *AccountWebBrowserSettingsNotModified ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode account.webBrowserSettingsNotModified#c31c8f4e as nil" )
}
return nil
}
func (w *AccountWebBrowserSettingsNotModified ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode account.webBrowserSettingsNotModified#c31c8f4e to nil" )
}
if err := b .ConsumeID (AccountWebBrowserSettingsNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettingsNotModified#c31c8f4e: %w" , err )
}
return w .DecodeBare (b )
}
func (w *AccountWebBrowserSettingsNotModified ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode account.webBrowserSettingsNotModified#c31c8f4e to nil" )
}
return nil
}
type AccountWebBrowserSettings struct {
Flags bin .Fields
OpenExternalBrowser bool
DisplayCloseButton bool
ExternalExceptions []WebDomainException
InappExceptions []WebDomainException
Hash int64
}
const AccountWebBrowserSettingsTypeID = 0x79eb8cb3
func (w AccountWebBrowserSettings ) construct () AccountWebBrowserSettingsClass { return &w }
var (
_ bin .Encoder = &AccountWebBrowserSettings {}
_ bin .Decoder = &AccountWebBrowserSettings {}
_ bin .BareEncoder = &AccountWebBrowserSettings {}
_ bin .BareDecoder = &AccountWebBrowserSettings {}
_ AccountWebBrowserSettingsClass = &AccountWebBrowserSettings {}
)
func (w *AccountWebBrowserSettings ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .OpenExternalBrowser == false ) {
return false
}
if !(w .DisplayCloseButton == false ) {
return false
}
if !(w .ExternalExceptions == nil ) {
return false
}
if !(w .InappExceptions == nil ) {
return false
}
if !(w .Hash == 0 ) {
return false
}
return true
}
func (w *AccountWebBrowserSettings ) String () string {
if w == nil {
return "AccountWebBrowserSettings(nil)"
}
type Alias AccountWebBrowserSettings
return fmt .Sprintf ("AccountWebBrowserSettings%+v" , Alias (*w ))
}
func (w *AccountWebBrowserSettings ) FillFrom (from interface {
GetOpenExternalBrowser () (value bool )
GetDisplayCloseButton () (value bool )
GetExternalExceptions () (value []WebDomainException )
GetInappExceptions () (value []WebDomainException )
GetHash () (value int64 )
}) {
w .OpenExternalBrowser = from .GetOpenExternalBrowser ()
w .DisplayCloseButton = from .GetDisplayCloseButton ()
w .ExternalExceptions = from .GetExternalExceptions ()
w .InappExceptions = from .GetInappExceptions ()
w .Hash = from .GetHash ()
}
func (*AccountWebBrowserSettings ) TypeID () uint32 {
return AccountWebBrowserSettingsTypeID
}
func (*AccountWebBrowserSettings ) TypeName () string {
return "account.webBrowserSettings"
}
func (w *AccountWebBrowserSettings ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.webBrowserSettings" ,
ID : AccountWebBrowserSettingsTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "OpenExternalBrowser" ,
SchemaName : "open_external_browser" ,
Null : !w .Flags .Has (0 ),
},
{
Name : "DisplayCloseButton" ,
SchemaName : "display_close_button" ,
Null : !w .Flags .Has (1 ),
},
{
Name : "ExternalExceptions" ,
SchemaName : "external_exceptions" ,
},
{
Name : "InappExceptions" ,
SchemaName : "inapp_exceptions" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (w *AccountWebBrowserSettings ) SetFlags () {
if !(w .OpenExternalBrowser == false ) {
w .Flags .Set (0 )
}
if !(w .DisplayCloseButton == false ) {
w .Flags .Set (1 )
}
}
func (w *AccountWebBrowserSettings ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode account.webBrowserSettings#79eb8cb3 as nil" )
}
b .PutID (AccountWebBrowserSettingsTypeID )
return w .EncodeBare (b )
}
func (w *AccountWebBrowserSettings ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode account.webBrowserSettings#79eb8cb3 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.webBrowserSettings#79eb8cb3: field flags: %w" , err )
}
b .PutVectorHeader (len (w .ExternalExceptions ))
for idx , v := range w .ExternalExceptions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.webBrowserSettings#79eb8cb3: field external_exceptions element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (w .InappExceptions ))
for idx , v := range w .InappExceptions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.webBrowserSettings#79eb8cb3: field inapp_exceptions element with index %d: %w" , idx , err )
}
}
b .PutLong (w .Hash )
return nil
}
func (w *AccountWebBrowserSettings ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode account.webBrowserSettings#79eb8cb3 to nil" )
}
if err := b .ConsumeID (AccountWebBrowserSettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettings#79eb8cb3: %w" , err )
}
return w .DecodeBare (b )
}
func (w *AccountWebBrowserSettings ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode account.webBrowserSettings#79eb8cb3 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettings#79eb8cb3: field flags: %w" , err )
}
}
w .OpenExternalBrowser = w .Flags .Has (0 )
w .DisplayCloseButton = w .Flags .Has (1 )
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettings#79eb8cb3: field external_exceptions: %w" , err )
}
if headerLen > 0 {
w .ExternalExceptions = make ([]WebDomainException , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value WebDomainException
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettings#79eb8cb3: field external_exceptions: %w" , err )
}
w .ExternalExceptions = append (w .ExternalExceptions , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettings#79eb8cb3: field inapp_exceptions: %w" , err )
}
if headerLen > 0 {
w .InappExceptions = make ([]WebDomainException , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value WebDomainException
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettings#79eb8cb3: field inapp_exceptions: %w" , err )
}
w .InappExceptions = append (w .InappExceptions , value )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.webBrowserSettings#79eb8cb3: field hash: %w" , err )
}
w .Hash = value
}
return nil
}
func (w *AccountWebBrowserSettings ) SetOpenExternalBrowser (value bool ) {
if value {
w .Flags .Set (0 )
w .OpenExternalBrowser = true
} else {
w .Flags .Unset (0 )
w .OpenExternalBrowser = false
}
}
func (w *AccountWebBrowserSettings ) GetOpenExternalBrowser () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (0 )
}
func (w *AccountWebBrowserSettings ) SetDisplayCloseButton (value bool ) {
if value {
w .Flags .Set (1 )
w .DisplayCloseButton = true
} else {
w .Flags .Unset (1 )
w .DisplayCloseButton = false
}
}
func (w *AccountWebBrowserSettings ) GetDisplayCloseButton () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (1 )
}
func (w *AccountWebBrowserSettings ) GetExternalExceptions () (value []WebDomainException ) {
if w == nil {
return
}
return w .ExternalExceptions
}
func (w *AccountWebBrowserSettings ) GetInappExceptions () (value []WebDomainException ) {
if w == nil {
return
}
return w .InappExceptions
}
func (w *AccountWebBrowserSettings ) GetHash () (value int64 ) {
if w == nil {
return
}
return w .Hash
}
const AccountWebBrowserSettingsClassName = "account.WebBrowserSettings"
type AccountWebBrowserSettingsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () AccountWebBrowserSettingsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*AccountWebBrowserSettings , bool )
}
func (w *AccountWebBrowserSettingsNotModified ) AsModified () (*AccountWebBrowserSettings , bool ) {
return nil , false
}
func (w *AccountWebBrowserSettings ) AsModified () (*AccountWebBrowserSettings , bool ) {
return w , true
}
func DecodeAccountWebBrowserSettings (buf *bin .Buffer ) (AccountWebBrowserSettingsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case AccountWebBrowserSettingsNotModifiedTypeID :
v := AccountWebBrowserSettingsNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountWebBrowserSettingsClass: %w" , err )
}
return &v , nil
case AccountWebBrowserSettingsTypeID :
v := AccountWebBrowserSettings {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountWebBrowserSettingsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode AccountWebBrowserSettingsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type AccountWebBrowserSettingsBox struct {
WebBrowserSettings AccountWebBrowserSettingsClass
}
func (b *AccountWebBrowserSettingsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode AccountWebBrowserSettingsBox to nil" )
}
v , err := DecodeAccountWebBrowserSettings (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .WebBrowserSettings = v
return nil
}
func (b *AccountWebBrowserSettingsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .WebBrowserSettings == nil {
return fmt .Errorf ("unable to encode AccountWebBrowserSettingsClass as nil" )
}
return b .WebBrowserSettings .Encode (buf )
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .