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 AccountThemesNotModified struct {
}
const AccountThemesNotModifiedTypeID = 0xf41eb622
func (t AccountThemesNotModified ) construct () AccountThemesClass { return &t }
var (
_ bin .Encoder = &AccountThemesNotModified {}
_ bin .Decoder = &AccountThemesNotModified {}
_ bin .BareEncoder = &AccountThemesNotModified {}
_ bin .BareDecoder = &AccountThemesNotModified {}
_ AccountThemesClass = &AccountThemesNotModified {}
)
func (t *AccountThemesNotModified ) Zero () bool {
if t == nil {
return true
}
return true
}
func (t *AccountThemesNotModified ) String () string {
if t == nil {
return "AccountThemesNotModified(nil)"
}
type Alias AccountThemesNotModified
return fmt .Sprintf ("AccountThemesNotModified%+v" , Alias (*t ))
}
func (*AccountThemesNotModified ) TypeID () uint32 {
return AccountThemesNotModifiedTypeID
}
func (*AccountThemesNotModified ) TypeName () string {
return "account.themesNotModified"
}
func (t *AccountThemesNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.themesNotModified" ,
ID : AccountThemesNotModifiedTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (t *AccountThemesNotModified ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode account.themesNotModified#f41eb622 as nil" )
}
b .PutID (AccountThemesNotModifiedTypeID )
return t .EncodeBare (b )
}
func (t *AccountThemesNotModified ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode account.themesNotModified#f41eb622 as nil" )
}
return nil
}
func (t *AccountThemesNotModified ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode account.themesNotModified#f41eb622 to nil" )
}
if err := b .ConsumeID (AccountThemesNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.themesNotModified#f41eb622: %w" , err )
}
return t .DecodeBare (b )
}
func (t *AccountThemesNotModified ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode account.themesNotModified#f41eb622 to nil" )
}
return nil
}
type AccountThemes struct {
Hash int64
Themes []Theme
}
const AccountThemesTypeID = 0x9a3d8c6d
func (t AccountThemes ) construct () AccountThemesClass { return &t }
var (
_ bin .Encoder = &AccountThemes {}
_ bin .Decoder = &AccountThemes {}
_ bin .BareEncoder = &AccountThemes {}
_ bin .BareDecoder = &AccountThemes {}
_ AccountThemesClass = &AccountThemes {}
)
func (t *AccountThemes ) Zero () bool {
if t == nil {
return true
}
if !(t .Hash == 0 ) {
return false
}
if !(t .Themes == nil ) {
return false
}
return true
}
func (t *AccountThemes ) String () string {
if t == nil {
return "AccountThemes(nil)"
}
type Alias AccountThemes
return fmt .Sprintf ("AccountThemes%+v" , Alias (*t ))
}
func (t *AccountThemes ) FillFrom (from interface {
GetHash () (value int64 )
GetThemes () (value []Theme )
}) {
t .Hash = from .GetHash ()
t .Themes = from .GetThemes ()
}
func (*AccountThemes ) TypeID () uint32 {
return AccountThemesTypeID
}
func (*AccountThemes ) TypeName () string {
return "account.themes"
}
func (t *AccountThemes ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.themes" ,
ID : AccountThemesTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Themes" ,
SchemaName : "themes" ,
},
}
return typ
}
func (t *AccountThemes ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode account.themes#9a3d8c6d as nil" )
}
b .PutID (AccountThemesTypeID )
return t .EncodeBare (b )
}
func (t *AccountThemes ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode account.themes#9a3d8c6d as nil" )
}
b .PutLong (t .Hash )
b .PutVectorHeader (len (t .Themes ))
for idx , v := range t .Themes {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.themes#9a3d8c6d: field themes element with index %d: %w" , idx , err )
}
}
return nil
}
func (t *AccountThemes ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode account.themes#9a3d8c6d to nil" )
}
if err := b .ConsumeID (AccountThemesTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.themes#9a3d8c6d: %w" , err )
}
return t .DecodeBare (b )
}
func (t *AccountThemes ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode account.themes#9a3d8c6d to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.themes#9a3d8c6d: field hash: %w" , err )
}
t .Hash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.themes#9a3d8c6d: field themes: %w" , err )
}
if headerLen > 0 {
t .Themes = make ([]Theme , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value Theme
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.themes#9a3d8c6d: field themes: %w" , err )
}
t .Themes = append (t .Themes , value )
}
}
return nil
}
func (t *AccountThemes ) GetHash () (value int64 ) {
if t == nil {
return
}
return t .Hash
}
func (t *AccountThemes ) GetThemes () (value []Theme ) {
if t == nil {
return
}
return t .Themes
}
const AccountThemesClassName = "account.Themes"
type AccountThemesClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () AccountThemesClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*AccountThemes , bool )
}
func (t *AccountThemesNotModified ) AsModified () (*AccountThemes , bool ) {
return nil , false
}
func (t *AccountThemes ) AsModified () (*AccountThemes , bool ) {
return t , true
}
func DecodeAccountThemes (buf *bin .Buffer ) (AccountThemesClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case AccountThemesNotModifiedTypeID :
v := AccountThemesNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountThemesClass: %w" , err )
}
return &v , nil
case AccountThemesTypeID :
v := AccountThemes {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountThemesClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode AccountThemesClass: %w" , bin .NewUnexpectedID (id ))
}
}
type AccountThemesBox struct {
Themes AccountThemesClass
}
func (b *AccountThemesBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode AccountThemesBox to nil" )
}
v , err := DecodeAccountThemes (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Themes = v
return nil
}
func (b *AccountThemesBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Themes == nil {
return fmt .Errorf ("unable to encode AccountThemesClass as nil" )
}
return b .Themes .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 .