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 UploadWebFile struct {
Size int
MimeType string
FileType StorageFileTypeClass
Mtime int
Bytes []byte
}
const UploadWebFileTypeID = 0x21e753bc
var (
_ bin .Encoder = &UploadWebFile {}
_ bin .Decoder = &UploadWebFile {}
_ bin .BareEncoder = &UploadWebFile {}
_ bin .BareDecoder = &UploadWebFile {}
)
func (w *UploadWebFile ) Zero () bool {
if w == nil {
return true
}
if !(w .Size == 0 ) {
return false
}
if !(w .MimeType == "" ) {
return false
}
if !(w .FileType == nil ) {
return false
}
if !(w .Mtime == 0 ) {
return false
}
if !(w .Bytes == nil ) {
return false
}
return true
}
func (w *UploadWebFile ) String () string {
if w == nil {
return "UploadWebFile(nil)"
}
type Alias UploadWebFile
return fmt .Sprintf ("UploadWebFile%+v" , Alias (*w ))
}
func (w *UploadWebFile ) FillFrom (from interface {
GetSize () (value int )
GetMimeType () (value string )
GetFileType () (value StorageFileTypeClass )
GetMtime () (value int )
GetBytes () (value []byte )
}) {
w .Size = from .GetSize ()
w .MimeType = from .GetMimeType ()
w .FileType = from .GetFileType ()
w .Mtime = from .GetMtime ()
w .Bytes = from .GetBytes ()
}
func (*UploadWebFile ) TypeID () uint32 {
return UploadWebFileTypeID
}
func (*UploadWebFile ) TypeName () string {
return "upload.webFile"
}
func (w *UploadWebFile ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "upload.webFile" ,
ID : UploadWebFileTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Size" ,
SchemaName : "size" ,
},
{
Name : "MimeType" ,
SchemaName : "mime_type" ,
},
{
Name : "FileType" ,
SchemaName : "file_type" ,
},
{
Name : "Mtime" ,
SchemaName : "mtime" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
}
return typ
}
func (w *UploadWebFile ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode upload.webFile#21e753bc as nil" )
}
b .PutID (UploadWebFileTypeID )
return w .EncodeBare (b )
}
func (w *UploadWebFile ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode upload.webFile#21e753bc as nil" )
}
b .PutInt (w .Size )
b .PutString (w .MimeType )
if w .FileType == nil {
return fmt .Errorf ("unable to encode upload.webFile#21e753bc: field file_type is nil" )
}
if err := w .FileType .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode upload.webFile#21e753bc: field file_type: %w" , err )
}
b .PutInt (w .Mtime )
b .PutBytes (w .Bytes )
return nil
}
func (w *UploadWebFile ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode upload.webFile#21e753bc to nil" )
}
if err := b .ConsumeID (UploadWebFileTypeID ); err != nil {
return fmt .Errorf ("unable to decode upload.webFile#21e753bc: %w" , err )
}
return w .DecodeBare (b )
}
func (w *UploadWebFile ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode upload.webFile#21e753bc to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode upload.webFile#21e753bc: field size: %w" , err )
}
w .Size = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode upload.webFile#21e753bc: field mime_type: %w" , err )
}
w .MimeType = value
}
{
value , err := DecodeStorageFileType (b )
if err != nil {
return fmt .Errorf ("unable to decode upload.webFile#21e753bc: field file_type: %w" , err )
}
w .FileType = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode upload.webFile#21e753bc: field mtime: %w" , err )
}
w .Mtime = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode upload.webFile#21e753bc: field bytes: %w" , err )
}
w .Bytes = value
}
return nil
}
func (w *UploadWebFile ) GetSize () (value int ) {
if w == nil {
return
}
return w .Size
}
func (w *UploadWebFile ) GetMimeType () (value string ) {
if w == nil {
return
}
return w .MimeType
}
func (w *UploadWebFile ) GetFileType () (value StorageFileTypeClass ) {
if w == nil {
return
}
return w .FileType
}
func (w *UploadWebFile ) GetMtime () (value int ) {
if w == nil {
return
}
return w .Mtime
}
func (w *UploadWebFile ) GetBytes () (value []byte ) {
if w == nil {
return
}
return w .Bytes
}
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 .