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 FileHash struct {
Offset int64
Limit int
Hash []byte
}
const FileHashTypeID = 0xf39b035c
var (
_ bin .Encoder = &FileHash {}
_ bin .Decoder = &FileHash {}
_ bin .BareEncoder = &FileHash {}
_ bin .BareDecoder = &FileHash {}
)
func (f *FileHash ) Zero () bool {
if f == nil {
return true
}
if !(f .Offset == 0 ) {
return false
}
if !(f .Limit == 0 ) {
return false
}
if !(f .Hash == nil ) {
return false
}
return true
}
func (f *FileHash ) String () string {
if f == nil {
return "FileHash(nil)"
}
type Alias FileHash
return fmt .Sprintf ("FileHash%+v" , Alias (*f ))
}
func (f *FileHash ) FillFrom (from interface {
GetOffset () (value int64 )
GetLimit () (value int )
GetHash () (value []byte )
}) {
f .Offset = from .GetOffset ()
f .Limit = from .GetLimit ()
f .Hash = from .GetHash ()
}
func (*FileHash ) TypeID () uint32 {
return FileHashTypeID
}
func (*FileHash ) TypeName () string {
return "fileHash"
}
func (f *FileHash ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "fileHash" ,
ID : FileHashTypeID ,
}
if f == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Offset" ,
SchemaName : "offset" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (f *FileHash ) Encode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode fileHash#f39b035c as nil" )
}
b .PutID (FileHashTypeID )
return f .EncodeBare (b )
}
func (f *FileHash ) EncodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode fileHash#f39b035c as nil" )
}
b .PutLong (f .Offset )
b .PutInt (f .Limit )
b .PutBytes (f .Hash )
return nil
}
func (f *FileHash ) Decode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode fileHash#f39b035c to nil" )
}
if err := b .ConsumeID (FileHashTypeID ); err != nil {
return fmt .Errorf ("unable to decode fileHash#f39b035c: %w" , err )
}
return f .DecodeBare (b )
}
func (f *FileHash ) DecodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode fileHash#f39b035c to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode fileHash#f39b035c: field offset: %w" , err )
}
f .Offset = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode fileHash#f39b035c: field limit: %w" , err )
}
f .Limit = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode fileHash#f39b035c: field hash: %w" , err )
}
f .Hash = value
}
return nil
}
func (f *FileHash ) GetOffset () (value int64 ) {
if f == nil {
return
}
return f .Offset
}
func (f *FileHash ) GetLimit () (value int ) {
if f == nil {
return
}
return f .Limit
}
func (f *FileHash ) GetHash () (value []byte ) {
if f == nil {
return
}
return f .Hash
}
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 .