package mt
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 MsgContainer struct {
Messages []Message
}
const MsgContainerTypeID = 0x73f1f8dc
var (
_ bin .Encoder = &MsgContainer {}
_ bin .Decoder = &MsgContainer {}
_ bin .BareEncoder = &MsgContainer {}
_ bin .BareDecoder = &MsgContainer {}
)
func (m *MsgContainer ) Zero () bool {
if m == nil {
return true
}
if !(m .Messages == nil ) {
return false
}
return true
}
func (m *MsgContainer ) String () string {
if m == nil {
return "MsgContainer(nil)"
}
type Alias MsgContainer
return fmt .Sprintf ("MsgContainer%+v" , Alias (*m ))
}
func (*MsgContainer ) TypeID () uint32 {
return MsgContainerTypeID
}
func (*MsgContainer ) TypeName () string {
return "msg_container"
}
func (m *MsgContainer ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "msg_container" ,
ID : MsgContainerTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Messages" ,
SchemaName : "messages" ,
},
}
return typ
}
func (m *MsgContainer ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode msg_container#73f1f8dc as nil" )
}
b .PutID (MsgContainerTypeID )
return m .EncodeBare (b )
}
func (m *MsgContainer ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode msg_container#73f1f8dc as nil" )
}
b .PutInt (len (m .Messages ))
for idx , v := range m .Messages {
if err := v .EncodeBare (b ); err != nil {
return fmt .Errorf ("unable to encode bare msg_container#73f1f8dc: field messages element with index %d: %w" , idx , err )
}
}
return nil
}
func (m *MsgContainer ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode msg_container#73f1f8dc to nil" )
}
if err := b .ConsumeID (MsgContainerTypeID ); err != nil {
return fmt .Errorf ("unable to decode msg_container#73f1f8dc: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MsgContainer ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode msg_container#73f1f8dc to nil" )
}
{
headerLen , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode msg_container#73f1f8dc: field messages: %w" , err )
}
if headerLen > 0 {
m .Messages = make ([]Message , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value Message
if err := value .DecodeBare (b ); err != nil {
return fmt .Errorf ("unable to decode bare msg_container#73f1f8dc: field messages: %w" , err )
}
m .Messages = append (m .Messages , value )
}
}
return nil
}
func (m *MsgContainer ) GetMessages () (value []Message ) {
if m == nil {
return
}
return m .Messages
}
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 .