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 UpdatesChannelDifferenceEmpty struct {
Flags bin .Fields
Final bool
Pts int
Timeout int
}
const UpdatesChannelDifferenceEmptyTypeID = 0x3e11affb
func (c UpdatesChannelDifferenceEmpty ) construct () UpdatesChannelDifferenceClass { return &c }
var (
_ bin .Encoder = &UpdatesChannelDifferenceEmpty {}
_ bin .Decoder = &UpdatesChannelDifferenceEmpty {}
_ bin .BareEncoder = &UpdatesChannelDifferenceEmpty {}
_ bin .BareDecoder = &UpdatesChannelDifferenceEmpty {}
_ UpdatesChannelDifferenceClass = &UpdatesChannelDifferenceEmpty {}
)
func (c *UpdatesChannelDifferenceEmpty ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Final == false ) {
return false
}
if !(c .Pts == 0 ) {
return false
}
if !(c .Timeout == 0 ) {
return false
}
return true
}
func (c *UpdatesChannelDifferenceEmpty ) String () string {
if c == nil {
return "UpdatesChannelDifferenceEmpty(nil)"
}
type Alias UpdatesChannelDifferenceEmpty
return fmt .Sprintf ("UpdatesChannelDifferenceEmpty%+v" , Alias (*c ))
}
func (c *UpdatesChannelDifferenceEmpty ) FillFrom (from interface {
GetFinal () (value bool )
GetPts () (value int )
GetTimeout () (value int , ok bool )
}) {
c .Final = from .GetFinal ()
c .Pts = from .GetPts ()
if val , ok := from .GetTimeout (); ok {
c .Timeout = val
}
}
func (*UpdatesChannelDifferenceEmpty ) TypeID () uint32 {
return UpdatesChannelDifferenceEmptyTypeID
}
func (*UpdatesChannelDifferenceEmpty ) TypeName () string {
return "updates.channelDifferenceEmpty"
}
func (c *UpdatesChannelDifferenceEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updates.channelDifferenceEmpty" ,
ID : UpdatesChannelDifferenceEmptyTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Final" ,
SchemaName : "final" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Pts" ,
SchemaName : "pts" ,
},
{
Name : "Timeout" ,
SchemaName : "timeout" ,
Null : !c .Flags .Has (1 ),
},
}
return typ
}
func (c *UpdatesChannelDifferenceEmpty ) SetFlags () {
if !(c .Final == false ) {
c .Flags .Set (0 )
}
if !(c .Timeout == 0 ) {
c .Flags .Set (1 )
}
}
func (c *UpdatesChannelDifferenceEmpty ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode updates.channelDifferenceEmpty#3e11affb as nil" )
}
b .PutID (UpdatesChannelDifferenceEmptyTypeID )
return c .EncodeBare (b )
}
func (c *UpdatesChannelDifferenceEmpty ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode updates.channelDifferenceEmpty#3e11affb as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceEmpty#3e11affb: field flags: %w" , err )
}
b .PutInt (c .Pts )
if c .Flags .Has (1 ) {
b .PutInt (c .Timeout )
}
return nil
}
func (c *UpdatesChannelDifferenceEmpty ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode updates.channelDifferenceEmpty#3e11affb to nil" )
}
if err := b .ConsumeID (UpdatesChannelDifferenceEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceEmpty#3e11affb: %w" , err )
}
return c .DecodeBare (b )
}
func (c *UpdatesChannelDifferenceEmpty ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode updates.channelDifferenceEmpty#3e11affb to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceEmpty#3e11affb: field flags: %w" , err )
}
}
c .Final = c .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceEmpty#3e11affb: field pts: %w" , err )
}
c .Pts = value
}
if c .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceEmpty#3e11affb: field timeout: %w" , err )
}
c .Timeout = value
}
return nil
}
func (c *UpdatesChannelDifferenceEmpty ) SetFinal (value bool ) {
if value {
c .Flags .Set (0 )
c .Final = true
} else {
c .Flags .Unset (0 )
c .Final = false
}
}
func (c *UpdatesChannelDifferenceEmpty ) GetFinal () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *UpdatesChannelDifferenceEmpty ) GetPts () (value int ) {
if c == nil {
return
}
return c .Pts
}
func (c *UpdatesChannelDifferenceEmpty ) SetTimeout (value int ) {
c .Flags .Set (1 )
c .Timeout = value
}
func (c *UpdatesChannelDifferenceEmpty ) GetTimeout () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .Timeout , true
}
type UpdatesChannelDifferenceTooLong struct {
Flags bin .Fields
Final bool
Timeout int
Dialog DialogClass
Messages []MessageClass
Chats []ChatClass
Users []UserClass
}
const UpdatesChannelDifferenceTooLongTypeID = 0xa4bcc6fe
func (c UpdatesChannelDifferenceTooLong ) construct () UpdatesChannelDifferenceClass { return &c }
var (
_ bin .Encoder = &UpdatesChannelDifferenceTooLong {}
_ bin .Decoder = &UpdatesChannelDifferenceTooLong {}
_ bin .BareEncoder = &UpdatesChannelDifferenceTooLong {}
_ bin .BareDecoder = &UpdatesChannelDifferenceTooLong {}
_ UpdatesChannelDifferenceClass = &UpdatesChannelDifferenceTooLong {}
)
func (c *UpdatesChannelDifferenceTooLong ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Final == false ) {
return false
}
if !(c .Timeout == 0 ) {
return false
}
if !(c .Dialog == nil ) {
return false
}
if !(c .Messages == nil ) {
return false
}
if !(c .Chats == nil ) {
return false
}
if !(c .Users == nil ) {
return false
}
return true
}
func (c *UpdatesChannelDifferenceTooLong ) String () string {
if c == nil {
return "UpdatesChannelDifferenceTooLong(nil)"
}
type Alias UpdatesChannelDifferenceTooLong
return fmt .Sprintf ("UpdatesChannelDifferenceTooLong%+v" , Alias (*c ))
}
func (c *UpdatesChannelDifferenceTooLong ) FillFrom (from interface {
GetFinal () (value bool )
GetTimeout () (value int , ok bool )
GetDialog () (value DialogClass )
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
c .Final = from .GetFinal ()
if val , ok := from .GetTimeout (); ok {
c .Timeout = val
}
c .Dialog = from .GetDialog ()
c .Messages = from .GetMessages ()
c .Chats = from .GetChats ()
c .Users = from .GetUsers ()
}
func (*UpdatesChannelDifferenceTooLong ) TypeID () uint32 {
return UpdatesChannelDifferenceTooLongTypeID
}
func (*UpdatesChannelDifferenceTooLong ) TypeName () string {
return "updates.channelDifferenceTooLong"
}
func (c *UpdatesChannelDifferenceTooLong ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updates.channelDifferenceTooLong" ,
ID : UpdatesChannelDifferenceTooLongTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Final" ,
SchemaName : "final" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Timeout" ,
SchemaName : "timeout" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "Dialog" ,
SchemaName : "dialog" ,
},
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (c *UpdatesChannelDifferenceTooLong ) SetFlags () {
if !(c .Final == false ) {
c .Flags .Set (0 )
}
if !(c .Timeout == 0 ) {
c .Flags .Set (1 )
}
}
func (c *UpdatesChannelDifferenceTooLong ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode updates.channelDifferenceTooLong#a4bcc6fe as nil" )
}
b .PutID (UpdatesChannelDifferenceTooLongTypeID )
return c .EncodeBare (b )
}
func (c *UpdatesChannelDifferenceTooLong ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode updates.channelDifferenceTooLong#a4bcc6fe as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceTooLong#a4bcc6fe: field flags: %w" , err )
}
if c .Flags .Has (1 ) {
b .PutInt (c .Timeout )
}
if c .Dialog == nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceTooLong#a4bcc6fe: field dialog is nil" )
}
if err := c .Dialog .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceTooLong#a4bcc6fe: field dialog: %w" , err )
}
b .PutVectorHeader (len (c .Messages ))
for idx , v := range c .Messages {
if v == nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceTooLong#a4bcc6fe: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceTooLong#a4bcc6fe: field messages 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 updates.channelDifferenceTooLong#a4bcc6fe: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceTooLong#a4bcc6fe: 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 updates.channelDifferenceTooLong#a4bcc6fe: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifferenceTooLong#a4bcc6fe: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *UpdatesChannelDifferenceTooLong ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode updates.channelDifferenceTooLong#a4bcc6fe to nil" )
}
if err := b .ConsumeID (UpdatesChannelDifferenceTooLongTypeID ); err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: %w" , err )
}
return c .DecodeBare (b )
}
func (c *UpdatesChannelDifferenceTooLong ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode updates.channelDifferenceTooLong#a4bcc6fe to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: field flags: %w" , err )
}
}
c .Final = c .Flags .Has (0 )
if c .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: field timeout: %w" , err )
}
c .Timeout = value
}
{
value , err := DecodeDialog (b )
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: field dialog: %w" , err )
}
c .Dialog = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: field messages: %w" , err )
}
if headerLen > 0 {
c .Messages = make ([]MessageClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: field messages: %w" , err )
}
c .Messages = append (c .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: 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 updates.channelDifferenceTooLong#a4bcc6fe: field chats: %w" , err )
}
c .Chats = append (c .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifferenceTooLong#a4bcc6fe: 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 updates.channelDifferenceTooLong#a4bcc6fe: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
return nil
}
func (c *UpdatesChannelDifferenceTooLong ) SetFinal (value bool ) {
if value {
c .Flags .Set (0 )
c .Final = true
} else {
c .Flags .Unset (0 )
c .Final = false
}
}
func (c *UpdatesChannelDifferenceTooLong ) GetFinal () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *UpdatesChannelDifferenceTooLong ) SetTimeout (value int ) {
c .Flags .Set (1 )
c .Timeout = value
}
func (c *UpdatesChannelDifferenceTooLong ) GetTimeout () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .Timeout , true
}
func (c *UpdatesChannelDifferenceTooLong ) GetDialog () (value DialogClass ) {
if c == nil {
return
}
return c .Dialog
}
func (c *UpdatesChannelDifferenceTooLong ) GetMessages () (value []MessageClass ) {
if c == nil {
return
}
return c .Messages
}
func (c *UpdatesChannelDifferenceTooLong ) GetChats () (value []ChatClass ) {
if c == nil {
return
}
return c .Chats
}
func (c *UpdatesChannelDifferenceTooLong ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *UpdatesChannelDifferenceTooLong ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (c .Messages )
}
func (c *UpdatesChannelDifferenceTooLong ) MapChats () (value ChatClassArray ) {
return ChatClassArray (c .Chats )
}
func (c *UpdatesChannelDifferenceTooLong ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .Users )
}
type UpdatesChannelDifference struct {
Flags bin .Fields
Final bool
Pts int
Timeout int
NewMessages []MessageClass
OtherUpdates []UpdateClass
Chats []ChatClass
Users []UserClass
}
const UpdatesChannelDifferenceTypeID = 0x2064674e
func (c UpdatesChannelDifference ) construct () UpdatesChannelDifferenceClass { return &c }
var (
_ bin .Encoder = &UpdatesChannelDifference {}
_ bin .Decoder = &UpdatesChannelDifference {}
_ bin .BareEncoder = &UpdatesChannelDifference {}
_ bin .BareDecoder = &UpdatesChannelDifference {}
_ UpdatesChannelDifferenceClass = &UpdatesChannelDifference {}
)
func (c *UpdatesChannelDifference ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Final == false ) {
return false
}
if !(c .Pts == 0 ) {
return false
}
if !(c .Timeout == 0 ) {
return false
}
if !(c .NewMessages == nil ) {
return false
}
if !(c .OtherUpdates == nil ) {
return false
}
if !(c .Chats == nil ) {
return false
}
if !(c .Users == nil ) {
return false
}
return true
}
func (c *UpdatesChannelDifference ) String () string {
if c == nil {
return "UpdatesChannelDifference(nil)"
}
type Alias UpdatesChannelDifference
return fmt .Sprintf ("UpdatesChannelDifference%+v" , Alias (*c ))
}
func (c *UpdatesChannelDifference ) FillFrom (from interface {
GetFinal () (value bool )
GetPts () (value int )
GetTimeout () (value int , ok bool )
GetNewMessages () (value []MessageClass )
GetOtherUpdates () (value []UpdateClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
c .Final = from .GetFinal ()
c .Pts = from .GetPts ()
if val , ok := from .GetTimeout (); ok {
c .Timeout = val
}
c .NewMessages = from .GetNewMessages ()
c .OtherUpdates = from .GetOtherUpdates ()
c .Chats = from .GetChats ()
c .Users = from .GetUsers ()
}
func (*UpdatesChannelDifference ) TypeID () uint32 {
return UpdatesChannelDifferenceTypeID
}
func (*UpdatesChannelDifference ) TypeName () string {
return "updates.channelDifference"
}
func (c *UpdatesChannelDifference ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updates.channelDifference" ,
ID : UpdatesChannelDifferenceTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Final" ,
SchemaName : "final" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Pts" ,
SchemaName : "pts" ,
},
{
Name : "Timeout" ,
SchemaName : "timeout" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "NewMessages" ,
SchemaName : "new_messages" ,
},
{
Name : "OtherUpdates" ,
SchemaName : "other_updates" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (c *UpdatesChannelDifference ) SetFlags () {
if !(c .Final == false ) {
c .Flags .Set (0 )
}
if !(c .Timeout == 0 ) {
c .Flags .Set (1 )
}
}
func (c *UpdatesChannelDifference ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode updates.channelDifference#2064674e as nil" )
}
b .PutID (UpdatesChannelDifferenceTypeID )
return c .EncodeBare (b )
}
func (c *UpdatesChannelDifference ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode updates.channelDifference#2064674e as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifference#2064674e: field flags: %w" , err )
}
b .PutInt (c .Pts )
if c .Flags .Has (1 ) {
b .PutInt (c .Timeout )
}
b .PutVectorHeader (len (c .NewMessages ))
for idx , v := range c .NewMessages {
if v == nil {
return fmt .Errorf ("unable to encode updates.channelDifference#2064674e: field new_messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifference#2064674e: field new_messages element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .OtherUpdates ))
for idx , v := range c .OtherUpdates {
if v == nil {
return fmt .Errorf ("unable to encode updates.channelDifference#2064674e: field other_updates element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifference#2064674e: field other_updates 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 updates.channelDifference#2064674e: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifference#2064674e: 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 updates.channelDifference#2064674e: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates.channelDifference#2064674e: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *UpdatesChannelDifference ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode updates.channelDifference#2064674e to nil" )
}
if err := b .ConsumeID (UpdatesChannelDifferenceTypeID ); err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: %w" , err )
}
return c .DecodeBare (b )
}
func (c *UpdatesChannelDifference ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode updates.channelDifference#2064674e to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: field flags: %w" , err )
}
}
c .Final = c .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: field pts: %w" , err )
}
c .Pts = value
}
if c .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: field timeout: %w" , err )
}
c .Timeout = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: field new_messages: %w" , err )
}
if headerLen > 0 {
c .NewMessages = make ([]MessageClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: field new_messages: %w" , err )
}
c .NewMessages = append (c .NewMessages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: field other_updates: %w" , err )
}
if headerLen > 0 {
c .OtherUpdates = make ([]UpdateClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUpdate (b )
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: field other_updates: %w" , err )
}
c .OtherUpdates = append (c .OtherUpdates , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: 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 updates.channelDifference#2064674e: field chats: %w" , err )
}
c .Chats = append (c .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates.channelDifference#2064674e: 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 updates.channelDifference#2064674e: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
return nil
}
func (c *UpdatesChannelDifference ) SetFinal (value bool ) {
if value {
c .Flags .Set (0 )
c .Final = true
} else {
c .Flags .Unset (0 )
c .Final = false
}
}
func (c *UpdatesChannelDifference ) GetFinal () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *UpdatesChannelDifference ) GetPts () (value int ) {
if c == nil {
return
}
return c .Pts
}
func (c *UpdatesChannelDifference ) SetTimeout (value int ) {
c .Flags .Set (1 )
c .Timeout = value
}
func (c *UpdatesChannelDifference ) GetTimeout () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .Timeout , true
}
func (c *UpdatesChannelDifference ) GetNewMessages () (value []MessageClass ) {
if c == nil {
return
}
return c .NewMessages
}
func (c *UpdatesChannelDifference ) GetOtherUpdates () (value []UpdateClass ) {
if c == nil {
return
}
return c .OtherUpdates
}
func (c *UpdatesChannelDifference ) GetChats () (value []ChatClass ) {
if c == nil {
return
}
return c .Chats
}
func (c *UpdatesChannelDifference ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *UpdatesChannelDifference ) MapNewMessages () (value MessageClassArray ) {
return MessageClassArray (c .NewMessages )
}
func (c *UpdatesChannelDifference ) MapOtherUpdates () (value UpdateClassArray ) {
return UpdateClassArray (c .OtherUpdates )
}
func (c *UpdatesChannelDifference ) MapChats () (value ChatClassArray ) {
return ChatClassArray (c .Chats )
}
func (c *UpdatesChannelDifference ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .Users )
}
const UpdatesChannelDifferenceClassName = "updates.ChannelDifference"
type UpdatesChannelDifferenceClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () UpdatesChannelDifferenceClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetFinal () (value bool )
GetTimeout () (value int , ok bool )
AsNotEmpty () (NotEmptyUpdatesChannelDifference , bool )
}
type NotEmptyUpdatesChannelDifference interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () UpdatesChannelDifferenceClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetFinal () (value bool )
GetTimeout () (value int , ok bool )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}
func (c *UpdatesChannelDifferenceEmpty ) AsNotEmpty () (NotEmptyUpdatesChannelDifference , bool ) {
value , ok := (UpdatesChannelDifferenceClass (c )).(NotEmptyUpdatesChannelDifference )
return value , ok
}
func (c *UpdatesChannelDifferenceTooLong ) AsNotEmpty () (NotEmptyUpdatesChannelDifference , bool ) {
value , ok := (UpdatesChannelDifferenceClass (c )).(NotEmptyUpdatesChannelDifference )
return value , ok
}
func (c *UpdatesChannelDifference ) AsNotEmpty () (NotEmptyUpdatesChannelDifference , bool ) {
value , ok := (UpdatesChannelDifferenceClass (c )).(NotEmptyUpdatesChannelDifference )
return value , ok
}
func DecodeUpdatesChannelDifference (buf *bin .Buffer ) (UpdatesChannelDifferenceClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case UpdatesChannelDifferenceEmptyTypeID :
v := UpdatesChannelDifferenceEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesChannelDifferenceClass: %w" , err )
}
return &v , nil
case UpdatesChannelDifferenceTooLongTypeID :
v := UpdatesChannelDifferenceTooLong {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesChannelDifferenceClass: %w" , err )
}
return &v , nil
case UpdatesChannelDifferenceTypeID :
v := UpdatesChannelDifference {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesChannelDifferenceClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode UpdatesChannelDifferenceClass: %w" , bin .NewUnexpectedID (id ))
}
}
type UpdatesChannelDifferenceBox struct {
ChannelDifference UpdatesChannelDifferenceClass
}
func (b *UpdatesChannelDifferenceBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode UpdatesChannelDifferenceBox to nil" )
}
v , err := DecodeUpdatesChannelDifference (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChannelDifference = v
return nil
}
func (b *UpdatesChannelDifferenceBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChannelDifference == nil {
return fmt .Errorf ("unable to encode UpdatesChannelDifferenceClass as nil" )
}
return b .ChannelDifference .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 .