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 EncryptedFileEmpty struct {
}
const EncryptedFileEmptyTypeID = 0xc21f497e
func (e EncryptedFileEmpty ) construct () EncryptedFileClass { return &e }
var (
_ bin .Encoder = &EncryptedFileEmpty {}
_ bin .Decoder = &EncryptedFileEmpty {}
_ bin .BareEncoder = &EncryptedFileEmpty {}
_ bin .BareDecoder = &EncryptedFileEmpty {}
_ EncryptedFileClass = &EncryptedFileEmpty {}
)
func (e *EncryptedFileEmpty ) Zero () bool {
if e == nil {
return true
}
return true
}
func (e *EncryptedFileEmpty ) String () string {
if e == nil {
return "EncryptedFileEmpty(nil)"
}
type Alias EncryptedFileEmpty
return fmt .Sprintf ("EncryptedFileEmpty%+v" , Alias (*e ))
}
func (*EncryptedFileEmpty ) TypeID () uint32 {
return EncryptedFileEmptyTypeID
}
func (*EncryptedFileEmpty ) TypeName () string {
return "encryptedFileEmpty"
}
func (e *EncryptedFileEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "encryptedFileEmpty" ,
ID : EncryptedFileEmptyTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (e *EncryptedFileEmpty ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedFileEmpty#c21f497e as nil" )
}
b .PutID (EncryptedFileEmptyTypeID )
return e .EncodeBare (b )
}
func (e *EncryptedFileEmpty ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedFileEmpty#c21f497e as nil" )
}
return nil
}
func (e *EncryptedFileEmpty ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedFileEmpty#c21f497e to nil" )
}
if err := b .ConsumeID (EncryptedFileEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode encryptedFileEmpty#c21f497e: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EncryptedFileEmpty ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedFileEmpty#c21f497e to nil" )
}
return nil
}
type EncryptedFile struct {
ID int64
AccessHash int64
Size int64
DCID int
KeyFingerprint int
}
const EncryptedFileTypeID = 0xa8008cd8
func (e EncryptedFile ) construct () EncryptedFileClass { return &e }
var (
_ bin .Encoder = &EncryptedFile {}
_ bin .Decoder = &EncryptedFile {}
_ bin .BareEncoder = &EncryptedFile {}
_ bin .BareDecoder = &EncryptedFile {}
_ EncryptedFileClass = &EncryptedFile {}
)
func (e *EncryptedFile ) Zero () bool {
if e == nil {
return true
}
if !(e .ID == 0 ) {
return false
}
if !(e .AccessHash == 0 ) {
return false
}
if !(e .Size == 0 ) {
return false
}
if !(e .DCID == 0 ) {
return false
}
if !(e .KeyFingerprint == 0 ) {
return false
}
return true
}
func (e *EncryptedFile ) String () string {
if e == nil {
return "EncryptedFile(nil)"
}
type Alias EncryptedFile
return fmt .Sprintf ("EncryptedFile%+v" , Alias (*e ))
}
func (e *EncryptedFile ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
GetSize () (value int64 )
GetDCID () (value int )
GetKeyFingerprint () (value int )
}) {
e .ID = from .GetID ()
e .AccessHash = from .GetAccessHash ()
e .Size = from .GetSize ()
e .DCID = from .GetDCID ()
e .KeyFingerprint = from .GetKeyFingerprint ()
}
func (*EncryptedFile ) TypeID () uint32 {
return EncryptedFileTypeID
}
func (*EncryptedFile ) TypeName () string {
return "encryptedFile"
}
func (e *EncryptedFile ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "encryptedFile" ,
ID : EncryptedFileTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "Size" ,
SchemaName : "size" ,
},
{
Name : "DCID" ,
SchemaName : "dc_id" ,
},
{
Name : "KeyFingerprint" ,
SchemaName : "key_fingerprint" ,
},
}
return typ
}
func (e *EncryptedFile ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedFile#a8008cd8 as nil" )
}
b .PutID (EncryptedFileTypeID )
return e .EncodeBare (b )
}
func (e *EncryptedFile ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedFile#a8008cd8 as nil" )
}
b .PutLong (e .ID )
b .PutLong (e .AccessHash )
b .PutLong (e .Size )
b .PutInt (e .DCID )
b .PutInt (e .KeyFingerprint )
return nil
}
func (e *EncryptedFile ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedFile#a8008cd8 to nil" )
}
if err := b .ConsumeID (EncryptedFileTypeID ); err != nil {
return fmt .Errorf ("unable to decode encryptedFile#a8008cd8: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EncryptedFile ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedFile#a8008cd8 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedFile#a8008cd8: field id: %w" , err )
}
e .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedFile#a8008cd8: field access_hash: %w" , err )
}
e .AccessHash = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedFile#a8008cd8: field size: %w" , err )
}
e .Size = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedFile#a8008cd8: field dc_id: %w" , err )
}
e .DCID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedFile#a8008cd8: field key_fingerprint: %w" , err )
}
e .KeyFingerprint = value
}
return nil
}
func (e *EncryptedFile ) GetID () (value int64 ) {
if e == nil {
return
}
return e .ID
}
func (e *EncryptedFile ) GetAccessHash () (value int64 ) {
if e == nil {
return
}
return e .AccessHash
}
func (e *EncryptedFile ) GetSize () (value int64 ) {
if e == nil {
return
}
return e .Size
}
func (e *EncryptedFile ) GetDCID () (value int ) {
if e == nil {
return
}
return e .DCID
}
func (e *EncryptedFile ) GetKeyFingerprint () (value int ) {
if e == nil {
return
}
return e .KeyFingerprint
}
const EncryptedFileClassName = "EncryptedFile"
type EncryptedFileClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () EncryptedFileClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*EncryptedFile , bool )
}
func (e *EncryptedFile ) AsInputEncryptedFileLocation () *InputEncryptedFileLocation {
value := new (InputEncryptedFileLocation )
value .ID = e .GetID ()
value .AccessHash = e .GetAccessHash ()
return value
}
func (e *EncryptedFile ) AsInput () *InputEncryptedFile {
value := new (InputEncryptedFile )
value .ID = e .GetID ()
value .AccessHash = e .GetAccessHash ()
return value
}
func (e *EncryptedFileEmpty ) AsNotEmpty () (*EncryptedFile , bool ) {
return nil , false
}
func (e *EncryptedFile ) AsNotEmpty () (*EncryptedFile , bool ) {
return e , true
}
func DecodeEncryptedFile (buf *bin .Buffer ) (EncryptedFileClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case EncryptedFileEmptyTypeID :
v := EncryptedFileEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EncryptedFileClass: %w" , err )
}
return &v , nil
case EncryptedFileTypeID :
v := EncryptedFile {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EncryptedFileClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode EncryptedFileClass: %w" , bin .NewUnexpectedID (id ))
}
}
type EncryptedFileBox struct {
EncryptedFile EncryptedFileClass
}
func (b *EncryptedFileBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode EncryptedFileBox to nil" )
}
v , err := DecodeEncryptedFile (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .EncryptedFile = v
return nil
}
func (b *EncryptedFileBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .EncryptedFile == nil {
return fmt .Errorf ("unable to encode EncryptedFileClass as nil" )
}
return b .EncryptedFile .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 .