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 InputDocumentEmpty struct {
}
const InputDocumentEmptyTypeID = 0x72f0eaae
func (i InputDocumentEmpty ) construct () InputDocumentClass { return &i }
var (
_ bin .Encoder = &InputDocumentEmpty {}
_ bin .Decoder = &InputDocumentEmpty {}
_ bin .BareEncoder = &InputDocumentEmpty {}
_ bin .BareDecoder = &InputDocumentEmpty {}
_ InputDocumentClass = &InputDocumentEmpty {}
)
func (i *InputDocumentEmpty ) Zero () bool {
if i == nil {
return true
}
return true
}
func (i *InputDocumentEmpty ) String () string {
if i == nil {
return "InputDocumentEmpty(nil)"
}
type Alias InputDocumentEmpty
return fmt .Sprintf ("InputDocumentEmpty%+v" , Alias (*i ))
}
func (*InputDocumentEmpty ) TypeID () uint32 {
return InputDocumentEmptyTypeID
}
func (*InputDocumentEmpty ) TypeName () string {
return "inputDocumentEmpty"
}
func (i *InputDocumentEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputDocumentEmpty" ,
ID : InputDocumentEmptyTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (i *InputDocumentEmpty ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputDocumentEmpty#72f0eaae as nil" )
}
b .PutID (InputDocumentEmptyTypeID )
return i .EncodeBare (b )
}
func (i *InputDocumentEmpty ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputDocumentEmpty#72f0eaae as nil" )
}
return nil
}
func (i *InputDocumentEmpty ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputDocumentEmpty#72f0eaae to nil" )
}
if err := b .ConsumeID (InputDocumentEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputDocumentEmpty#72f0eaae: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputDocumentEmpty ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputDocumentEmpty#72f0eaae to nil" )
}
return nil
}
type InputDocument struct {
ID int64
AccessHash int64
FileReference []byte
}
const InputDocumentTypeID = 0x1abfb575
func (i InputDocument ) construct () InputDocumentClass { return &i }
var (
_ bin .Encoder = &InputDocument {}
_ bin .Decoder = &InputDocument {}
_ bin .BareEncoder = &InputDocument {}
_ bin .BareDecoder = &InputDocument {}
_ InputDocumentClass = &InputDocument {}
)
func (i *InputDocument ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
if !(i .FileReference == nil ) {
return false
}
return true
}
func (i *InputDocument ) String () string {
if i == nil {
return "InputDocument(nil)"
}
type Alias InputDocument
return fmt .Sprintf ("InputDocument%+v" , Alias (*i ))
}
func (i *InputDocument ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
GetFileReference () (value []byte )
}) {
i .ID = from .GetID ()
i .AccessHash = from .GetAccessHash ()
i .FileReference = from .GetFileReference ()
}
func (*InputDocument ) TypeID () uint32 {
return InputDocumentTypeID
}
func (*InputDocument ) TypeName () string {
return "inputDocument"
}
func (i *InputDocument ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputDocument" ,
ID : InputDocumentTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "FileReference" ,
SchemaName : "file_reference" ,
},
}
return typ
}
func (i *InputDocument ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputDocument#1abfb575 as nil" )
}
b .PutID (InputDocumentTypeID )
return i .EncodeBare (b )
}
func (i *InputDocument ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputDocument#1abfb575 as nil" )
}
b .PutLong (i .ID )
b .PutLong (i .AccessHash )
b .PutBytes (i .FileReference )
return nil
}
func (i *InputDocument ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputDocument#1abfb575 to nil" )
}
if err := b .ConsumeID (InputDocumentTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputDocument#1abfb575: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputDocument ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputDocument#1abfb575 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputDocument#1abfb575: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputDocument#1abfb575: field access_hash: %w" , err )
}
i .AccessHash = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode inputDocument#1abfb575: field file_reference: %w" , err )
}
i .FileReference = value
}
return nil
}
func (i *InputDocument ) GetID () (value int64 ) {
if i == nil {
return
}
return i .ID
}
func (i *InputDocument ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
func (i *InputDocument ) GetFileReference () (value []byte ) {
if i == nil {
return
}
return i .FileReference
}
const InputDocumentClassName = "InputDocument"
type InputDocumentClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputDocumentClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*InputDocument , bool )
}
func (i *InputDocument ) AsInputDocumentFileLocation () *InputDocumentFileLocation {
value := new (InputDocumentFileLocation )
value .ID = i .GetID ()
value .AccessHash = i .GetAccessHash ()
value .FileReference = i .GetFileReference ()
return value
}
func (i *InputDocumentEmpty ) AsNotEmpty () (*InputDocument , bool ) {
return nil , false
}
func (i *InputDocument ) AsNotEmpty () (*InputDocument , bool ) {
return i , true
}
func DecodeInputDocument (buf *bin .Buffer ) (InputDocumentClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputDocumentEmptyTypeID :
v := InputDocumentEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputDocumentClass: %w" , err )
}
return &v , nil
case InputDocumentTypeID :
v := InputDocument {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputDocumentClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputDocumentClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputDocumentBox struct {
InputDocument InputDocumentClass
}
func (b *InputDocumentBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputDocumentBox to nil" )
}
v , err := DecodeInputDocument (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputDocument = v
return nil
}
func (b *InputDocumentBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputDocument == nil {
return fmt .Errorf ("unable to encode InputDocumentClass as nil" )
}
return b .InputDocument .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 .