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 TonConnectRequest struct {
Flags bin .Fields
SessionID int64
MsgID int
Body []byte
Expires int
Topic string
TraceID string
}
const TonConnectRequestTypeID = 0xa15f8513
var (
_ bin .Encoder = &TonConnectRequest {}
_ bin .Decoder = &TonConnectRequest {}
_ bin .BareEncoder = &TonConnectRequest {}
_ bin .BareDecoder = &TonConnectRequest {}
)
func (t *TonConnectRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .SessionID == 0 ) {
return false
}
if !(t .MsgID == 0 ) {
return false
}
if !(t .Body == nil ) {
return false
}
if !(t .Expires == 0 ) {
return false
}
if !(t .Topic == "" ) {
return false
}
if !(t .TraceID == "" ) {
return false
}
return true
}
func (t *TonConnectRequest ) String () string {
if t == nil {
return "TonConnectRequest(nil)"
}
type Alias TonConnectRequest
return fmt .Sprintf ("TonConnectRequest%+v" , Alias (*t ))
}
func (t *TonConnectRequest ) FillFrom (from interface {
GetSessionID () (value int64 )
GetMsgID () (value int )
GetBody () (value []byte )
GetExpires () (value int )
GetTopic () (value string , ok bool )
GetTraceID () (value string , ok bool )
}) {
t .SessionID = from .GetSessionID ()
t .MsgID = from .GetMsgID ()
t .Body = from .GetBody ()
t .Expires = from .GetExpires ()
if val , ok := from .GetTopic (); ok {
t .Topic = val
}
if val , ok := from .GetTraceID (); ok {
t .TraceID = val
}
}
func (*TonConnectRequest ) TypeID () uint32 {
return TonConnectRequestTypeID
}
func (*TonConnectRequest ) TypeName () string {
return "tonConnectRequest"
}
func (t *TonConnectRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "tonConnectRequest" ,
ID : TonConnectRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "SessionID" ,
SchemaName : "session_id" ,
},
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
},
{
Name : "Body" ,
SchemaName : "body" ,
},
{
Name : "Expires" ,
SchemaName : "expires" ,
},
{
Name : "Topic" ,
SchemaName : "topic" ,
Null : !t .Flags .Has (0 ),
},
{
Name : "TraceID" ,
SchemaName : "trace_id" ,
Null : !t .Flags .Has (1 ),
},
}
return typ
}
func (t *TonConnectRequest ) SetFlags () {
if !(t .Topic == "" ) {
t .Flags .Set (0 )
}
if !(t .TraceID == "" ) {
t .Flags .Set (1 )
}
}
func (t *TonConnectRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode tonConnectRequest#a15f8513 as nil" )
}
b .PutID (TonConnectRequestTypeID )
return t .EncodeBare (b )
}
func (t *TonConnectRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode tonConnectRequest#a15f8513 as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode tonConnectRequest#a15f8513: field flags: %w" , err )
}
b .PutLong (t .SessionID )
b .PutInt (t .MsgID )
b .PutBytes (t .Body )
b .PutInt (t .Expires )
if t .Flags .Has (0 ) {
b .PutString (t .Topic )
}
if t .Flags .Has (1 ) {
b .PutString (t .TraceID )
}
return nil
}
func (t *TonConnectRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode tonConnectRequest#a15f8513 to nil" )
}
if err := b .ConsumeID (TonConnectRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: %w" , err )
}
return t .DecodeBare (b )
}
func (t *TonConnectRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode tonConnectRequest#a15f8513 to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: field session_id: %w" , err )
}
t .SessionID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: field msg_id: %w" , err )
}
t .MsgID = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: field body: %w" , err )
}
t .Body = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: field expires: %w" , err )
}
t .Expires = value
}
if t .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: field topic: %w" , err )
}
t .Topic = value
}
if t .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectRequest#a15f8513: field trace_id: %w" , err )
}
t .TraceID = value
}
return nil
}
func (t *TonConnectRequest ) GetSessionID () (value int64 ) {
if t == nil {
return
}
return t .SessionID
}
func (t *TonConnectRequest ) GetMsgID () (value int ) {
if t == nil {
return
}
return t .MsgID
}
func (t *TonConnectRequest ) GetBody () (value []byte ) {
if t == nil {
return
}
return t .Body
}
func (t *TonConnectRequest ) GetExpires () (value int ) {
if t == nil {
return
}
return t .Expires
}
func (t *TonConnectRequest ) SetTopic (value string ) {
t .Flags .Set (0 )
t .Topic = value
}
func (t *TonConnectRequest ) GetTopic () (value string , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (0 ) {
return value , false
}
return t .Topic , true
}
func (t *TonConnectRequest ) SetTraceID (value string ) {
t .Flags .Set (1 )
t .TraceID = value
}
func (t *TonConnectRequest ) GetTraceID () (value string , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (1 ) {
return value , false
}
return t .TraceID , true
}
The pages are generated with Golds v0.8.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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .