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 MessagesChats struct {
Chats []ChatClass
}
const MessagesChatsTypeID = 0x64ff9fd5
func (c MessagesChats ) construct () MessagesChatsClass { return &c }
var (
_ bin .Encoder = &MessagesChats {}
_ bin .Decoder = &MessagesChats {}
_ bin .BareEncoder = &MessagesChats {}
_ bin .BareDecoder = &MessagesChats {}
_ MessagesChatsClass = &MessagesChats {}
)
func (c *MessagesChats ) Zero () bool {
if c == nil {
return true
}
if !(c .Chats == nil ) {
return false
}
return true
}
func (c *MessagesChats ) String () string {
if c == nil {
return "MessagesChats(nil)"
}
type Alias MessagesChats
return fmt .Sprintf ("MessagesChats%+v" , Alias (*c ))
}
func (c *MessagesChats ) FillFrom (from interface {
GetChats () (value []ChatClass )
}) {
c .Chats = from .GetChats ()
}
func (*MessagesChats ) TypeID () uint32 {
return MessagesChatsTypeID
}
func (*MessagesChats ) TypeName () string {
return "messages.chats"
}
func (c *MessagesChats ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.chats" ,
ID : MessagesChatsTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Chats" ,
SchemaName : "chats" ,
},
}
return typ
}
func (c *MessagesChats ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chats#64ff9fd5 as nil" )
}
b .PutID (MessagesChatsTypeID )
return c .EncodeBare (b )
}
func (c *MessagesChats ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chats#64ff9fd5 as nil" )
}
b .PutVectorHeader (len (c .Chats ))
for idx , v := range c .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.chats#64ff9fd5: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.chats#64ff9fd5: field chats element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *MessagesChats ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chats#64ff9fd5 to nil" )
}
if err := b .ConsumeID (MessagesChatsTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.chats#64ff9fd5: %w" , err )
}
return c .DecodeBare (b )
}
func (c *MessagesChats ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chats#64ff9fd5 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.chats#64ff9fd5: 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 messages.chats#64ff9fd5: field chats: %w" , err )
}
c .Chats = append (c .Chats , value )
}
}
return nil
}
func (c *MessagesChats ) GetChats () (value []ChatClass ) {
if c == nil {
return
}
return c .Chats
}
func (c *MessagesChats ) MapChats () (value ChatClassArray ) {
return ChatClassArray (c .Chats )
}
type MessagesChatsSlice struct {
Count int
Chats []ChatClass
}
const MessagesChatsSliceTypeID = 0x9cd81144
func (c MessagesChatsSlice ) construct () MessagesChatsClass { return &c }
var (
_ bin .Encoder = &MessagesChatsSlice {}
_ bin .Decoder = &MessagesChatsSlice {}
_ bin .BareEncoder = &MessagesChatsSlice {}
_ bin .BareDecoder = &MessagesChatsSlice {}
_ MessagesChatsClass = &MessagesChatsSlice {}
)
func (c *MessagesChatsSlice ) Zero () bool {
if c == nil {
return true
}
if !(c .Count == 0 ) {
return false
}
if !(c .Chats == nil ) {
return false
}
return true
}
func (c *MessagesChatsSlice ) String () string {
if c == nil {
return "MessagesChatsSlice(nil)"
}
type Alias MessagesChatsSlice
return fmt .Sprintf ("MessagesChatsSlice%+v" , Alias (*c ))
}
func (c *MessagesChatsSlice ) FillFrom (from interface {
GetCount () (value int )
GetChats () (value []ChatClass )
}) {
c .Count = from .GetCount ()
c .Chats = from .GetChats ()
}
func (*MessagesChatsSlice ) TypeID () uint32 {
return MessagesChatsSliceTypeID
}
func (*MessagesChatsSlice ) TypeName () string {
return "messages.chatsSlice"
}
func (c *MessagesChatsSlice ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.chatsSlice" ,
ID : MessagesChatsSliceTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
}
return typ
}
func (c *MessagesChatsSlice ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chatsSlice#9cd81144 as nil" )
}
b .PutID (MessagesChatsSliceTypeID )
return c .EncodeBare (b )
}
func (c *MessagesChatsSlice ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chatsSlice#9cd81144 as nil" )
}
b .PutInt (c .Count )
b .PutVectorHeader (len (c .Chats ))
for idx , v := range c .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.chatsSlice#9cd81144: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.chatsSlice#9cd81144: field chats element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *MessagesChatsSlice ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chatsSlice#9cd81144 to nil" )
}
if err := b .ConsumeID (MessagesChatsSliceTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.chatsSlice#9cd81144: %w" , err )
}
return c .DecodeBare (b )
}
func (c *MessagesChatsSlice ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chatsSlice#9cd81144 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.chatsSlice#9cd81144: field count: %w" , err )
}
c .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.chatsSlice#9cd81144: 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 messages.chatsSlice#9cd81144: field chats: %w" , err )
}
c .Chats = append (c .Chats , value )
}
}
return nil
}
func (c *MessagesChatsSlice ) GetCount () (value int ) {
if c == nil {
return
}
return c .Count
}
func (c *MessagesChatsSlice ) GetChats () (value []ChatClass ) {
if c == nil {
return
}
return c .Chats
}
func (c *MessagesChatsSlice ) MapChats () (value ChatClassArray ) {
return ChatClassArray (c .Chats )
}
const MessagesChatsClassName = "messages.Chats"
type MessagesChatsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesChatsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetChats () (value []ChatClass )
MapChats () (value ChatClassArray )
}
func DecodeMessagesChats (buf *bin .Buffer ) (MessagesChatsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesChatsTypeID :
v := MessagesChats {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesChatsClass: %w" , err )
}
return &v , nil
case MessagesChatsSliceTypeID :
v := MessagesChatsSlice {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesChatsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesChatsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesChatsBox struct {
Chats MessagesChatsClass
}
func (b *MessagesChatsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesChatsBox to nil" )
}
v , err := DecodeMessagesChats (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Chats = v
return nil
}
func (b *MessagesChatsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Chats == nil {
return fmt .Errorf ("unable to encode MessagesChatsClass as nil" )
}
return b .Chats .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 .