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 AccountChatThemesNotModified struct {
}
const AccountChatThemesNotModifiedTypeID = 0xe011e1c4
func (c AccountChatThemesNotModified ) construct () AccountChatThemesClass { return &c }
var (
_ bin .Encoder = &AccountChatThemesNotModified {}
_ bin .Decoder = &AccountChatThemesNotModified {}
_ bin .BareEncoder = &AccountChatThemesNotModified {}
_ bin .BareDecoder = &AccountChatThemesNotModified {}
_ AccountChatThemesClass = &AccountChatThemesNotModified {}
)
func (c *AccountChatThemesNotModified ) Zero () bool {
if c == nil {
return true
}
return true
}
func (c *AccountChatThemesNotModified ) String () string {
if c == nil {
return "AccountChatThemesNotModified(nil)"
}
type Alias AccountChatThemesNotModified
return fmt .Sprintf ("AccountChatThemesNotModified%+v" , Alias (*c ))
}
func (*AccountChatThemesNotModified ) TypeID () uint32 {
return AccountChatThemesNotModifiedTypeID
}
func (*AccountChatThemesNotModified ) TypeName () string {
return "account.chatThemesNotModified"
}
func (c *AccountChatThemesNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.chatThemesNotModified" ,
ID : AccountChatThemesNotModifiedTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (c *AccountChatThemesNotModified ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.chatThemesNotModified#e011e1c4 as nil" )
}
b .PutID (AccountChatThemesNotModifiedTypeID )
return c .EncodeBare (b )
}
func (c *AccountChatThemesNotModified ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.chatThemesNotModified#e011e1c4 as nil" )
}
return nil
}
func (c *AccountChatThemesNotModified ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.chatThemesNotModified#e011e1c4 to nil" )
}
if err := b .ConsumeID (AccountChatThemesNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.chatThemesNotModified#e011e1c4: %w" , err )
}
return c .DecodeBare (b )
}
func (c *AccountChatThemesNotModified ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.chatThemesNotModified#e011e1c4 to nil" )
}
return nil
}
type AccountChatThemes struct {
Flags bin .Fields
Hash int64
Themes []ChatThemeClass
Chats []ChatClass
Users []UserClass
NextOffset string
}
const AccountChatThemesTypeID = 0xbe098173
func (c AccountChatThemes ) construct () AccountChatThemesClass { return &c }
var (
_ bin .Encoder = &AccountChatThemes {}
_ bin .Decoder = &AccountChatThemes {}
_ bin .BareEncoder = &AccountChatThemes {}
_ bin .BareDecoder = &AccountChatThemes {}
_ AccountChatThemesClass = &AccountChatThemes {}
)
func (c *AccountChatThemes ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Hash == 0 ) {
return false
}
if !(c .Themes == nil ) {
return false
}
if !(c .Chats == nil ) {
return false
}
if !(c .Users == nil ) {
return false
}
if !(c .NextOffset == "" ) {
return false
}
return true
}
func (c *AccountChatThemes ) String () string {
if c == nil {
return "AccountChatThemes(nil)"
}
type Alias AccountChatThemes
return fmt .Sprintf ("AccountChatThemes%+v" , Alias (*c ))
}
func (c *AccountChatThemes ) FillFrom (from interface {
GetHash () (value int64 )
GetThemes () (value []ChatThemeClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
GetNextOffset () (value string , ok bool )
}) {
c .Hash = from .GetHash ()
c .Themes = from .GetThemes ()
c .Chats = from .GetChats ()
c .Users = from .GetUsers ()
if val , ok := from .GetNextOffset (); ok {
c .NextOffset = val
}
}
func (*AccountChatThemes ) TypeID () uint32 {
return AccountChatThemesTypeID
}
func (*AccountChatThemes ) TypeName () string {
return "account.chatThemes"
}
func (c *AccountChatThemes ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.chatThemes" ,
ID : AccountChatThemesTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Themes" ,
SchemaName : "themes" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !c .Flags .Has (0 ),
},
}
return typ
}
func (c *AccountChatThemes ) SetFlags () {
if !(c .NextOffset == "" ) {
c .Flags .Set (0 )
}
}
func (c *AccountChatThemes ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.chatThemes#be098173 as nil" )
}
b .PutID (AccountChatThemesTypeID )
return c .EncodeBare (b )
}
func (c *AccountChatThemes ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.chatThemes#be098173 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.chatThemes#be098173: field flags: %w" , err )
}
b .PutLong (c .Hash )
b .PutVectorHeader (len (c .Themes ))
for idx , v := range c .Themes {
if v == nil {
return fmt .Errorf ("unable to encode account.chatThemes#be098173: field themes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.chatThemes#be098173: field themes element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Chats ))
for idx , v := range c .Chats {
if v == nil {
return fmt .Errorf ("unable to encode account.chatThemes#be098173: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.chatThemes#be098173: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Users ))
for idx , v := range c .Users {
if v == nil {
return fmt .Errorf ("unable to encode account.chatThemes#be098173: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.chatThemes#be098173: field users element with index %d: %w" , idx , err )
}
}
if c .Flags .Has (0 ) {
b .PutString (c .NextOffset )
}
return nil
}
func (c *AccountChatThemes ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.chatThemes#be098173 to nil" )
}
if err := b .ConsumeID (AccountChatThemesTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: %w" , err )
}
return c .DecodeBare (b )
}
func (c *AccountChatThemes ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.chatThemes#be098173 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: field hash: %w" , err )
}
c .Hash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: field themes: %w" , err )
}
if headerLen > 0 {
c .Themes = make ([]ChatThemeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChatTheme (b )
if err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: field themes: %w" , err )
}
c .Themes = append (c .Themes , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: field chats: %w" , err )
}
if headerLen > 0 {
c .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.chatThemes#be098173: field chats: %w" , err )
}
c .Chats = append (c .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: field users: %w" , err )
}
if headerLen > 0 {
c .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.chatThemes#be098173: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
if c .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.chatThemes#be098173: field next_offset: %w" , err )
}
c .NextOffset = value
}
return nil
}
func (c *AccountChatThemes ) GetHash () (value int64 ) {
if c == nil {
return
}
return c .Hash
}
func (c *AccountChatThemes ) GetThemes () (value []ChatThemeClass ) {
if c == nil {
return
}
return c .Themes
}
func (c *AccountChatThemes ) GetChats () (value []ChatClass ) {
if c == nil {
return
}
return c .Chats
}
func (c *AccountChatThemes ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *AccountChatThemes ) SetNextOffset (value string ) {
c .Flags .Set (0 )
c .NextOffset = value
}
func (c *AccountChatThemes ) GetNextOffset () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .NextOffset , true
}
func (c *AccountChatThemes ) MapThemes () (value ChatThemeClassArray ) {
return ChatThemeClassArray (c .Themes )
}
func (c *AccountChatThemes ) MapChats () (value ChatClassArray ) {
return ChatClassArray (c .Chats )
}
func (c *AccountChatThemes ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .Users )
}
const AccountChatThemesClassName = "account.ChatThemes"
type AccountChatThemesClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () AccountChatThemesClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*AccountChatThemes , bool )
}
func (c *AccountChatThemesNotModified ) AsModified () (*AccountChatThemes , bool ) {
return nil , false
}
func (c *AccountChatThemes ) AsModified () (*AccountChatThemes , bool ) {
return c , true
}
func DecodeAccountChatThemes (buf *bin .Buffer ) (AccountChatThemesClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case AccountChatThemesNotModifiedTypeID :
v := AccountChatThemesNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountChatThemesClass: %w" , err )
}
return &v , nil
case AccountChatThemesTypeID :
v := AccountChatThemes {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountChatThemesClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode AccountChatThemesClass: %w" , bin .NewUnexpectedID (id ))
}
}
type AccountChatThemesBox struct {
ChatThemes AccountChatThemesClass
}
func (b *AccountChatThemesBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode AccountChatThemesBox to nil" )
}
v , err := DecodeAccountChatThemes (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChatThemes = v
return nil
}
func (b *AccountChatThemesBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChatThemes == nil {
return fmt .Errorf ("unable to encode AccountChatThemesClass as nil" )
}
return b .ChatThemes .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 .