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 Message struct {
MsgID int64
Seqno int
Bytes int
Body GzipPacked
}
const MessageTypeID = 0x5bb8e511
var (
_ bin .Encoder = &Message {}
_ bin .Decoder = &Message {}
_ bin .BareEncoder = &Message {}
_ bin .BareDecoder = &Message {}
)
func (m *Message ) Zero () bool {
if m == nil {
return true
}
if !(m .MsgID == 0 ) {
return false
}
if !(m .Seqno == 0 ) {
return false
}
if !(m .Bytes == 0 ) {
return false
}
if !(m .Body .Zero ()) {
return false
}
return true
}
func (m *Message ) String () string {
if m == nil {
return "Message(nil)"
}
type Alias Message
return fmt .Sprintf ("Message%+v" , Alias (*m ))
}
func (*Message ) TypeID () uint32 {
return MessageTypeID
}
func (*Message ) TypeName () string {
return "message"
}
func (m *Message ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "message" ,
ID : MessageTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
},
{
Name : "Seqno" ,
SchemaName : "seqno" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
{
Name : "Body" ,
SchemaName : "body" ,
},
}
return typ
}
func (m *Message ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode message#5bb8e511 as nil" )
}
b .PutID (MessageTypeID )
return m .EncodeBare (b )
}
func (m *Message ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode message#5bb8e511 as nil" )
}
b .PutLong (m .MsgID )
b .PutInt (m .Seqno )
b .PutInt (m .Bytes )
if err := m .Body .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#5bb8e511: field body: %w" , err )
}
return nil
}
func (m *Message ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode message#5bb8e511 to nil" )
}
if err := b .ConsumeID (MessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode message#5bb8e511: %w" , err )
}
return m .DecodeBare (b )
}
func (m *Message ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode message#5bb8e511 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode message#5bb8e511: field msg_id: %w" , err )
}
m .MsgID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#5bb8e511: field seqno: %w" , err )
}
m .Seqno = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#5bb8e511: field bytes: %w" , err )
}
m .Bytes = value
}
{
if err := m .Body .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode message#5bb8e511: field body: %w" , err )
}
}
return nil
}
func (m *Message ) GetMsgID () (value int64 ) {
if m == nil {
return
}
return m .MsgID
}
func (m *Message ) GetSeqno () (value int ) {
if m == nil {
return
}
return m .Seqno
}
func (m *Message ) GetBytes () (value int ) {
if m == nil {
return
}
return m .Bytes
}
func (m *Message ) GetBody () (value GzipPacked ) {
if m == nil {
return
}
return m .Body
}
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 .