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 UploadSaveFilePartRequest struct {
FileID int64
FilePart int
Bytes []byte
}
const UploadSaveFilePartRequestTypeID = 0xb304a621
var (
_ bin .Encoder = &UploadSaveFilePartRequest {}
_ bin .Decoder = &UploadSaveFilePartRequest {}
_ bin .BareEncoder = &UploadSaveFilePartRequest {}
_ bin .BareDecoder = &UploadSaveFilePartRequest {}
)
func (s *UploadSaveFilePartRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .FileID == 0 ) {
return false
}
if !(s .FilePart == 0 ) {
return false
}
if !(s .Bytes == nil ) {
return false
}
return true
}
func (s *UploadSaveFilePartRequest ) String () string {
if s == nil {
return "UploadSaveFilePartRequest(nil)"
}
type Alias UploadSaveFilePartRequest
return fmt .Sprintf ("UploadSaveFilePartRequest%+v" , Alias (*s ))
}
func (s *UploadSaveFilePartRequest ) FillFrom (from interface {
GetFileID () (value int64 )
GetFilePart () (value int )
GetBytes () (value []byte )
}) {
s .FileID = from .GetFileID ()
s .FilePart = from .GetFilePart ()
s .Bytes = from .GetBytes ()
}
func (*UploadSaveFilePartRequest ) TypeID () uint32 {
return UploadSaveFilePartRequestTypeID
}
func (*UploadSaveFilePartRequest ) TypeName () string {
return "upload.saveFilePart"
}
func (s *UploadSaveFilePartRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "upload.saveFilePart" ,
ID : UploadSaveFilePartRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "FileID" ,
SchemaName : "file_id" ,
},
{
Name : "FilePart" ,
SchemaName : "file_part" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
}
return typ
}
func (s *UploadSaveFilePartRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode upload.saveFilePart#b304a621 as nil" )
}
b .PutID (UploadSaveFilePartRequestTypeID )
return s .EncodeBare (b )
}
func (s *UploadSaveFilePartRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode upload.saveFilePart#b304a621 as nil" )
}
b .PutLong (s .FileID )
b .PutInt (s .FilePart )
b .PutBytes (s .Bytes )
return nil
}
func (s *UploadSaveFilePartRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode upload.saveFilePart#b304a621 to nil" )
}
if err := b .ConsumeID (UploadSaveFilePartRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode upload.saveFilePart#b304a621: %w" , err )
}
return s .DecodeBare (b )
}
func (s *UploadSaveFilePartRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode upload.saveFilePart#b304a621 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode upload.saveFilePart#b304a621: field file_id: %w" , err )
}
s .FileID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode upload.saveFilePart#b304a621: field file_part: %w" , err )
}
s .FilePart = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode upload.saveFilePart#b304a621: field bytes: %w" , err )
}
s .Bytes = value
}
return nil
}
func (s *UploadSaveFilePartRequest ) GetFileID () (value int64 ) {
if s == nil {
return
}
return s .FileID
}
func (s *UploadSaveFilePartRequest ) GetFilePart () (value int ) {
if s == nil {
return
}
return s .FilePart
}
func (s *UploadSaveFilePartRequest ) GetBytes () (value []byte ) {
if s == nil {
return
}
return s .Bytes
}
func (c *Client ) UploadSaveFilePart (ctx context .Context , request *UploadSaveFilePartRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
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 .