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 AccountAutoSaveSettings struct {
UsersSettings AutoSaveSettings
ChatsSettings AutoSaveSettings
BroadcastsSettings AutoSaveSettings
Exceptions []AutoSaveException
Chats []ChatClass
Users []UserClass
}
const AccountAutoSaveSettingsTypeID = 0x4c3e069d
var (
_ bin .Encoder = &AccountAutoSaveSettings {}
_ bin .Decoder = &AccountAutoSaveSettings {}
_ bin .BareEncoder = &AccountAutoSaveSettings {}
_ bin .BareDecoder = &AccountAutoSaveSettings {}
)
func (a *AccountAutoSaveSettings ) Zero () bool {
if a == nil {
return true
}
if !(a .UsersSettings .Zero ()) {
return false
}
if !(a .ChatsSettings .Zero ()) {
return false
}
if !(a .BroadcastsSettings .Zero ()) {
return false
}
if !(a .Exceptions == nil ) {
return false
}
if !(a .Chats == nil ) {
return false
}
if !(a .Users == nil ) {
return false
}
return true
}
func (a *AccountAutoSaveSettings ) String () string {
if a == nil {
return "AccountAutoSaveSettings(nil)"
}
type Alias AccountAutoSaveSettings
return fmt .Sprintf ("AccountAutoSaveSettings%+v" , Alias (*a ))
}
func (a *AccountAutoSaveSettings ) FillFrom (from interface {
GetUsersSettings () (value AutoSaveSettings )
GetChatsSettings () (value AutoSaveSettings )
GetBroadcastsSettings () (value AutoSaveSettings )
GetExceptions () (value []AutoSaveException )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
a .UsersSettings = from .GetUsersSettings ()
a .ChatsSettings = from .GetChatsSettings ()
a .BroadcastsSettings = from .GetBroadcastsSettings ()
a .Exceptions = from .GetExceptions ()
a .Chats = from .GetChats ()
a .Users = from .GetUsers ()
}
func (*AccountAutoSaveSettings ) TypeID () uint32 {
return AccountAutoSaveSettingsTypeID
}
func (*AccountAutoSaveSettings ) TypeName () string {
return "account.autoSaveSettings"
}
func (a *AccountAutoSaveSettings ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.autoSaveSettings" ,
ID : AccountAutoSaveSettingsTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UsersSettings" ,
SchemaName : "users_settings" ,
},
{
Name : "ChatsSettings" ,
SchemaName : "chats_settings" ,
},
{
Name : "BroadcastsSettings" ,
SchemaName : "broadcasts_settings" ,
},
{
Name : "Exceptions" ,
SchemaName : "exceptions" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (a *AccountAutoSaveSettings ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode account.autoSaveSettings#4c3e069d as nil" )
}
b .PutID (AccountAutoSaveSettingsTypeID )
return a .EncodeBare (b )
}
func (a *AccountAutoSaveSettings ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode account.autoSaveSettings#4c3e069d as nil" )
}
if err := a .UsersSettings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field users_settings: %w" , err )
}
if err := a .ChatsSettings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field chats_settings: %w" , err )
}
if err := a .BroadcastsSettings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field broadcasts_settings: %w" , err )
}
b .PutVectorHeader (len (a .Exceptions ))
for idx , v := range a .Exceptions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field exceptions element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Chats ))
for idx , v := range a .Chats {
if v == nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Users ))
for idx , v := range a .Users {
if v == nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.autoSaveSettings#4c3e069d: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (a *AccountAutoSaveSettings ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode account.autoSaveSettings#4c3e069d to nil" )
}
if err := b .ConsumeID (AccountAutoSaveSettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AccountAutoSaveSettings ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode account.autoSaveSettings#4c3e069d to nil" )
}
{
if err := a .UsersSettings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field users_settings: %w" , err )
}
}
{
if err := a .ChatsSettings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field chats_settings: %w" , err )
}
}
{
if err := a .BroadcastsSettings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field broadcasts_settings: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field exceptions: %w" , err )
}
if headerLen > 0 {
a .Exceptions = make ([]AutoSaveException , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value AutoSaveException
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field exceptions: %w" , err )
}
a .Exceptions = append (a .Exceptions , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field chats: %w" , err )
}
if headerLen > 0 {
a .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field chats: %w" , err )
}
a .Chats = append (a .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field users: %w" , err )
}
if headerLen > 0 {
a .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode account.autoSaveSettings#4c3e069d: field users: %w" , err )
}
a .Users = append (a .Users , value )
}
}
return nil
}
func (a *AccountAutoSaveSettings ) GetUsersSettings () (value AutoSaveSettings ) {
if a == nil {
return
}
return a .UsersSettings
}
func (a *AccountAutoSaveSettings ) GetChatsSettings () (value AutoSaveSettings ) {
if a == nil {
return
}
return a .ChatsSettings
}
func (a *AccountAutoSaveSettings ) GetBroadcastsSettings () (value AutoSaveSettings ) {
if a == nil {
return
}
return a .BroadcastsSettings
}
func (a *AccountAutoSaveSettings ) GetExceptions () (value []AutoSaveException ) {
if a == nil {
return
}
return a .Exceptions
}
func (a *AccountAutoSaveSettings ) GetChats () (value []ChatClass ) {
if a == nil {
return
}
return a .Chats
}
func (a *AccountAutoSaveSettings ) GetUsers () (value []UserClass ) {
if a == nil {
return
}
return a .Users
}
func (a *AccountAutoSaveSettings ) MapChats () (value ChatClassArray ) {
return ChatClassArray (a .Chats )
}
func (a *AccountAutoSaveSettings ) MapUsers () (value UserClassArray ) {
return UserClassArray (a .Users )
}
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 .