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 UploadCDNFileReuploadNeeded struct {
RequestToken []byte
}
const UploadCDNFileReuploadNeededTypeID = 0xeea8e46e
func (c UploadCDNFileReuploadNeeded ) construct () UploadCDNFileClass { return &c }
var (
_ bin .Encoder = &UploadCDNFileReuploadNeeded {}
_ bin .Decoder = &UploadCDNFileReuploadNeeded {}
_ bin .BareEncoder = &UploadCDNFileReuploadNeeded {}
_ bin .BareDecoder = &UploadCDNFileReuploadNeeded {}
_ UploadCDNFileClass = &UploadCDNFileReuploadNeeded {}
)
func (c *UploadCDNFileReuploadNeeded ) Zero () bool {
if c == nil {
return true
}
if !(c .RequestToken == nil ) {
return false
}
return true
}
func (c *UploadCDNFileReuploadNeeded ) String () string {
if c == nil {
return "UploadCDNFileReuploadNeeded(nil)"
}
type Alias UploadCDNFileReuploadNeeded
return fmt .Sprintf ("UploadCDNFileReuploadNeeded%+v" , Alias (*c ))
}
func (c *UploadCDNFileReuploadNeeded ) FillFrom (from interface {
GetRequestToken () (value []byte )
}) {
c .RequestToken = from .GetRequestToken ()
}
func (*UploadCDNFileReuploadNeeded ) TypeID () uint32 {
return UploadCDNFileReuploadNeededTypeID
}
func (*UploadCDNFileReuploadNeeded ) TypeName () string {
return "upload.cdnFileReuploadNeeded"
}
func (c *UploadCDNFileReuploadNeeded ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "upload.cdnFileReuploadNeeded" ,
ID : UploadCDNFileReuploadNeededTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "RequestToken" ,
SchemaName : "request_token" ,
},
}
return typ
}
func (c *UploadCDNFileReuploadNeeded ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode upload.cdnFileReuploadNeeded#eea8e46e as nil" )
}
b .PutID (UploadCDNFileReuploadNeededTypeID )
return c .EncodeBare (b )
}
func (c *UploadCDNFileReuploadNeeded ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode upload.cdnFileReuploadNeeded#eea8e46e as nil" )
}
b .PutBytes (c .RequestToken )
return nil
}
func (c *UploadCDNFileReuploadNeeded ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode upload.cdnFileReuploadNeeded#eea8e46e to nil" )
}
if err := b .ConsumeID (UploadCDNFileReuploadNeededTypeID ); err != nil {
return fmt .Errorf ("unable to decode upload.cdnFileReuploadNeeded#eea8e46e: %w" , err )
}
return c .DecodeBare (b )
}
func (c *UploadCDNFileReuploadNeeded ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode upload.cdnFileReuploadNeeded#eea8e46e to nil" )
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode upload.cdnFileReuploadNeeded#eea8e46e: field request_token: %w" , err )
}
c .RequestToken = value
}
return nil
}
func (c *UploadCDNFileReuploadNeeded ) GetRequestToken () (value []byte ) {
if c == nil {
return
}
return c .RequestToken
}
type UploadCDNFile struct {
Bytes []byte
}
const UploadCDNFileTypeID = 0xa99fca4f
func (c UploadCDNFile ) construct () UploadCDNFileClass { return &c }
var (
_ bin .Encoder = &UploadCDNFile {}
_ bin .Decoder = &UploadCDNFile {}
_ bin .BareEncoder = &UploadCDNFile {}
_ bin .BareDecoder = &UploadCDNFile {}
_ UploadCDNFileClass = &UploadCDNFile {}
)
func (c *UploadCDNFile ) Zero () bool {
if c == nil {
return true
}
if !(c .Bytes == nil ) {
return false
}
return true
}
func (c *UploadCDNFile ) String () string {
if c == nil {
return "UploadCDNFile(nil)"
}
type Alias UploadCDNFile
return fmt .Sprintf ("UploadCDNFile%+v" , Alias (*c ))
}
func (c *UploadCDNFile ) FillFrom (from interface {
GetBytes () (value []byte )
}) {
c .Bytes = from .GetBytes ()
}
func (*UploadCDNFile ) TypeID () uint32 {
return UploadCDNFileTypeID
}
func (*UploadCDNFile ) TypeName () string {
return "upload.cdnFile"
}
func (c *UploadCDNFile ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "upload.cdnFile" ,
ID : UploadCDNFileTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
}
return typ
}
func (c *UploadCDNFile ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode upload.cdnFile#a99fca4f as nil" )
}
b .PutID (UploadCDNFileTypeID )
return c .EncodeBare (b )
}
func (c *UploadCDNFile ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode upload.cdnFile#a99fca4f as nil" )
}
b .PutBytes (c .Bytes )
return nil
}
func (c *UploadCDNFile ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode upload.cdnFile#a99fca4f to nil" )
}
if err := b .ConsumeID (UploadCDNFileTypeID ); err != nil {
return fmt .Errorf ("unable to decode upload.cdnFile#a99fca4f: %w" , err )
}
return c .DecodeBare (b )
}
func (c *UploadCDNFile ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode upload.cdnFile#a99fca4f to nil" )
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode upload.cdnFile#a99fca4f: field bytes: %w" , err )
}
c .Bytes = value
}
return nil
}
func (c *UploadCDNFile ) GetBytes () (value []byte ) {
if c == nil {
return
}
return c .Bytes
}
const UploadCDNFileClassName = "upload.CdnFile"
type UploadCDNFileClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () UploadCDNFileClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeUploadCDNFile (buf *bin .Buffer ) (UploadCDNFileClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case UploadCDNFileReuploadNeededTypeID :
v := UploadCDNFileReuploadNeeded {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UploadCDNFileClass: %w" , err )
}
return &v , nil
case UploadCDNFileTypeID :
v := UploadCDNFile {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UploadCDNFileClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode UploadCDNFileClass: %w" , bin .NewUnexpectedID (id ))
}
}
type UploadCDNFileBox struct {
CdnFile UploadCDNFileClass
}
func (b *UploadCDNFileBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode UploadCDNFileBox to nil" )
}
v , err := DecodeUploadCDNFile (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .CdnFile = v
return nil
}
func (b *UploadCDNFileBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .CdnFile == nil {
return fmt .Errorf ("unable to encode UploadCDNFileClass as nil" )
}
return b .CdnFile .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 .