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 InputFile struct {
ID int64
Parts int
Name string
MD5Checksum string
}
const InputFileTypeID = 0xf52ff27f
func (i InputFile ) construct () InputFileClass { return &i }
var (
_ bin .Encoder = &InputFile {}
_ bin .Decoder = &InputFile {}
_ bin .BareEncoder = &InputFile {}
_ bin .BareDecoder = &InputFile {}
_ InputFileClass = &InputFile {}
)
func (i *InputFile ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .Parts == 0 ) {
return false
}
if !(i .Name == "" ) {
return false
}
if !(i .MD5Checksum == "" ) {
return false
}
return true
}
func (i *InputFile ) String () string {
if i == nil {
return "InputFile(nil)"
}
type Alias InputFile
return fmt .Sprintf ("InputFile%+v" , Alias (*i ))
}
func (i *InputFile ) FillFrom (from interface {
GetID () (value int64 )
GetParts () (value int )
GetName () (value string )
GetMD5Checksum () (value string )
}) {
i .ID = from .GetID ()
i .Parts = from .GetParts ()
i .Name = from .GetName ()
i .MD5Checksum = from .GetMD5Checksum ()
}
func (*InputFile ) TypeID () uint32 {
return InputFileTypeID
}
func (*InputFile ) TypeName () string {
return "inputFile"
}
func (i *InputFile ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputFile" ,
ID : InputFileTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Parts" ,
SchemaName : "parts" ,
},
{
Name : "Name" ,
SchemaName : "name" ,
},
{
Name : "MD5Checksum" ,
SchemaName : "md5_checksum" ,
},
}
return typ
}
func (i *InputFile ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputFile#f52ff27f as nil" )
}
b .PutID (InputFileTypeID )
return i .EncodeBare (b )
}
func (i *InputFile ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputFile#f52ff27f as nil" )
}
b .PutLong (i .ID )
b .PutInt (i .Parts )
b .PutString (i .Name )
b .PutString (i .MD5Checksum )
return nil
}
func (i *InputFile ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputFile#f52ff27f to nil" )
}
if err := b .ConsumeID (InputFileTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputFile#f52ff27f: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputFile ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputFile#f52ff27f to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputFile#f52ff27f: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputFile#f52ff27f: field parts: %w" , err )
}
i .Parts = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputFile#f52ff27f: field name: %w" , err )
}
i .Name = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputFile#f52ff27f: field md5_checksum: %w" , err )
}
i .MD5Checksum = value
}
return nil
}
func (i *InputFile ) GetID () (value int64 ) {
if i == nil {
return
}
return i .ID
}
func (i *InputFile ) GetParts () (value int ) {
if i == nil {
return
}
return i .Parts
}
func (i *InputFile ) GetName () (value string ) {
if i == nil {
return
}
return i .Name
}
func (i *InputFile ) GetMD5Checksum () (value string ) {
if i == nil {
return
}
return i .MD5Checksum
}
type InputFileBig struct {
ID int64
Parts int
Name string
}
const InputFileBigTypeID = 0xfa4f0bb5
func (i InputFileBig ) construct () InputFileClass { return &i }
var (
_ bin .Encoder = &InputFileBig {}
_ bin .Decoder = &InputFileBig {}
_ bin .BareEncoder = &InputFileBig {}
_ bin .BareDecoder = &InputFileBig {}
_ InputFileClass = &InputFileBig {}
)
func (i *InputFileBig ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .Parts == 0 ) {
return false
}
if !(i .Name == "" ) {
return false
}
return true
}
func (i *InputFileBig ) String () string {
if i == nil {
return "InputFileBig(nil)"
}
type Alias InputFileBig
return fmt .Sprintf ("InputFileBig%+v" , Alias (*i ))
}
func (i *InputFileBig ) FillFrom (from interface {
GetID () (value int64 )
GetParts () (value int )
GetName () (value string )
}) {
i .ID = from .GetID ()
i .Parts = from .GetParts ()
i .Name = from .GetName ()
}
func (*InputFileBig ) TypeID () uint32 {
return InputFileBigTypeID
}
func (*InputFileBig ) TypeName () string {
return "inputFileBig"
}
func (i *InputFileBig ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputFileBig" ,
ID : InputFileBigTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Parts" ,
SchemaName : "parts" ,
},
{
Name : "Name" ,
SchemaName : "name" ,
},
}
return typ
}
func (i *InputFileBig ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputFileBig#fa4f0bb5 as nil" )
}
b .PutID (InputFileBigTypeID )
return i .EncodeBare (b )
}
func (i *InputFileBig ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputFileBig#fa4f0bb5 as nil" )
}
b .PutLong (i .ID )
b .PutInt (i .Parts )
b .PutString (i .Name )
return nil
}
func (i *InputFileBig ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputFileBig#fa4f0bb5 to nil" )
}
if err := b .ConsumeID (InputFileBigTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputFileBig#fa4f0bb5: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputFileBig ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputFileBig#fa4f0bb5 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputFileBig#fa4f0bb5: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputFileBig#fa4f0bb5: field parts: %w" , err )
}
i .Parts = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputFileBig#fa4f0bb5: field name: %w" , err )
}
i .Name = value
}
return nil
}
func (i *InputFileBig ) GetID () (value int64 ) {
if i == nil {
return
}
return i .ID
}
func (i *InputFileBig ) GetParts () (value int ) {
if i == nil {
return
}
return i .Parts
}
func (i *InputFileBig ) GetName () (value string ) {
if i == nil {
return
}
return i .Name
}
const InputFileClassName = "InputFile"
type InputFileClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputFileClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
GetParts () (value int )
GetName () (value string )
}
func DecodeInputFile (buf *bin .Buffer ) (InputFileClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputFileTypeID :
v := InputFile {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputFileClass: %w" , err )
}
return &v , nil
case InputFileBigTypeID :
v := InputFileBig {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputFileClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputFileClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputFileBox struct {
InputFile InputFileClass
}
func (b *InputFileBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputFileBox to nil" )
}
v , err := DecodeInputFile (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputFile = v
return nil
}
func (b *InputFileBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputFile == nil {
return fmt .Errorf ("unable to encode InputFileClass as nil" )
}
return b .InputFile .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 .