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 MessagesPeerDialogs struct {
Dialogs []DialogClass
Messages []MessageClass
Chats []ChatClass
Users []UserClass
State UpdatesState
}
const MessagesPeerDialogsTypeID = 0x3371c354
var (
_ bin .Encoder = &MessagesPeerDialogs {}
_ bin .Decoder = &MessagesPeerDialogs {}
_ bin .BareEncoder = &MessagesPeerDialogs {}
_ bin .BareDecoder = &MessagesPeerDialogs {}
)
func (p *MessagesPeerDialogs ) Zero () bool {
if p == nil {
return true
}
if !(p .Dialogs == nil ) {
return false
}
if !(p .Messages == nil ) {
return false
}
if !(p .Chats == nil ) {
return false
}
if !(p .Users == nil ) {
return false
}
if !(p .State .Zero ()) {
return false
}
return true
}
func (p *MessagesPeerDialogs ) String () string {
if p == nil {
return "MessagesPeerDialogs(nil)"
}
type Alias MessagesPeerDialogs
return fmt .Sprintf ("MessagesPeerDialogs%+v" , Alias (*p ))
}
func (p *MessagesPeerDialogs ) FillFrom (from interface {
GetDialogs () (value []DialogClass )
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
GetState () (value UpdatesState )
}) {
p .Dialogs = from .GetDialogs ()
p .Messages = from .GetMessages ()
p .Chats = from .GetChats ()
p .Users = from .GetUsers ()
p .State = from .GetState ()
}
func (*MessagesPeerDialogs ) TypeID () uint32 {
return MessagesPeerDialogsTypeID
}
func (*MessagesPeerDialogs ) TypeName () string {
return "messages.peerDialogs"
}
func (p *MessagesPeerDialogs ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.peerDialogs" ,
ID : MessagesPeerDialogsTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Dialogs" ,
SchemaName : "dialogs" ,
},
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "State" ,
SchemaName : "state" ,
},
}
return typ
}
func (p *MessagesPeerDialogs ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode messages.peerDialogs#3371c354 as nil" )
}
b .PutID (MessagesPeerDialogsTypeID )
return p .EncodeBare (b )
}
func (p *MessagesPeerDialogs ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode messages.peerDialogs#3371c354 as nil" )
}
b .PutVectorHeader (len (p .Dialogs ))
for idx , v := range p .Dialogs {
if v == nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field dialogs element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field dialogs element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .Messages ))
for idx , v := range p .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field messages element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .Chats ))
for idx , v := range p .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .Users ))
for idx , v := range p .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field users element with index %d: %w" , idx , err )
}
}
if err := p .State .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.peerDialogs#3371c354: field state: %w" , err )
}
return nil
}
func (p *MessagesPeerDialogs ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode messages.peerDialogs#3371c354 to nil" )
}
if err := b .ConsumeID (MessagesPeerDialogsTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.peerDialogs#3371c354: %w" , err )
}
return p .DecodeBare (b )
}
func (p *MessagesPeerDialogs ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode messages.peerDialogs#3371c354 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.peerDialogs#3371c354: field dialogs: %w" , err )
}
if headerLen > 0 {
p .Dialogs = make ([]DialogClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDialog (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.peerDialogs#3371c354: field dialogs: %w" , err )
}
p .Dialogs = append (p .Dialogs , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.peerDialogs#3371c354: field messages: %w" , err )
}
if headerLen > 0 {
p .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 messages.peerDialogs#3371c354: field messages: %w" , err )
}
p .Messages = append (p .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.peerDialogs#3371c354: field chats: %w" , err )
}
if headerLen > 0 {
p .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.peerDialogs#3371c354: field chats: %w" , err )
}
p .Chats = append (p .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.peerDialogs#3371c354: field users: %w" , err )
}
if headerLen > 0 {
p .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 messages.peerDialogs#3371c354: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
{
if err := p .State .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.peerDialogs#3371c354: field state: %w" , err )
}
}
return nil
}
func (p *MessagesPeerDialogs ) GetDialogs () (value []DialogClass ) {
if p == nil {
return
}
return p .Dialogs
}
func (p *MessagesPeerDialogs ) GetMessages () (value []MessageClass ) {
if p == nil {
return
}
return p .Messages
}
func (p *MessagesPeerDialogs ) GetChats () (value []ChatClass ) {
if p == nil {
return
}
return p .Chats
}
func (p *MessagesPeerDialogs ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *MessagesPeerDialogs ) GetState () (value UpdatesState ) {
if p == nil {
return
}
return p .State
}
func (p *MessagesPeerDialogs ) MapDialogs () (value DialogClassArray ) {
return DialogClassArray (p .Dialogs )
}
func (p *MessagesPeerDialogs ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (p .Messages )
}
func (p *MessagesPeerDialogs ) MapChats () (value ChatClassArray ) {
return ChatClassArray (p .Chats )
}
func (p *MessagesPeerDialogs ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .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 .