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 SecureFileEmpty struct {
}
const SecureFileEmptyTypeID = 0x64199744
func (s SecureFileEmpty ) construct () SecureFileClass { return &s }
var (
_ bin .Encoder = &SecureFileEmpty {}
_ bin .Decoder = &SecureFileEmpty {}
_ bin .BareEncoder = &SecureFileEmpty {}
_ bin .BareDecoder = &SecureFileEmpty {}
_ SecureFileClass = &SecureFileEmpty {}
)
func (s *SecureFileEmpty ) Zero () bool {
if s == nil {
return true
}
return true
}
func (s *SecureFileEmpty ) String () string {
if s == nil {
return "SecureFileEmpty(nil)"
}
type Alias SecureFileEmpty
return fmt .Sprintf ("SecureFileEmpty%+v" , Alias (*s ))
}
func (*SecureFileEmpty ) TypeID () uint32 {
return SecureFileEmptyTypeID
}
func (*SecureFileEmpty ) TypeName () string {
return "secureFileEmpty"
}
func (s *SecureFileEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "secureFileEmpty" ,
ID : SecureFileEmptyTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (s *SecureFileEmpty ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureFileEmpty#64199744 as nil" )
}
b .PutID (SecureFileEmptyTypeID )
return s .EncodeBare (b )
}
func (s *SecureFileEmpty ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureFileEmpty#64199744 as nil" )
}
return nil
}
func (s *SecureFileEmpty ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureFileEmpty#64199744 to nil" )
}
if err := b .ConsumeID (SecureFileEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode secureFileEmpty#64199744: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SecureFileEmpty ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureFileEmpty#64199744 to nil" )
}
return nil
}
type SecureFile struct {
ID int64
AccessHash int64
Size int64
DCID int
Date int
FileHash []byte
Secret []byte
}
const SecureFileTypeID = 0x7d09c27e
func (s SecureFile ) construct () SecureFileClass { return &s }
var (
_ bin .Encoder = &SecureFile {}
_ bin .Decoder = &SecureFile {}
_ bin .BareEncoder = &SecureFile {}
_ bin .BareDecoder = &SecureFile {}
_ SecureFileClass = &SecureFile {}
)
func (s *SecureFile ) Zero () bool {
if s == nil {
return true
}
if !(s .ID == 0 ) {
return false
}
if !(s .AccessHash == 0 ) {
return false
}
if !(s .Size == 0 ) {
return false
}
if !(s .DCID == 0 ) {
return false
}
if !(s .Date == 0 ) {
return false
}
if !(s .FileHash == nil ) {
return false
}
if !(s .Secret == nil ) {
return false
}
return true
}
func (s *SecureFile ) String () string {
if s == nil {
return "SecureFile(nil)"
}
type Alias SecureFile
return fmt .Sprintf ("SecureFile%+v" , Alias (*s ))
}
func (s *SecureFile ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
GetSize () (value int64 )
GetDCID () (value int )
GetDate () (value int )
GetFileHash () (value []byte )
GetSecret () (value []byte )
}) {
s .ID = from .GetID ()
s .AccessHash = from .GetAccessHash ()
s .Size = from .GetSize ()
s .DCID = from .GetDCID ()
s .Date = from .GetDate ()
s .FileHash = from .GetFileHash ()
s .Secret = from .GetSecret ()
}
func (*SecureFile ) TypeID () uint32 {
return SecureFileTypeID
}
func (*SecureFile ) TypeName () string {
return "secureFile"
}
func (s *SecureFile ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "secureFile" ,
ID : SecureFileTypeID ,
}
if s == 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 : "Date" ,
SchemaName : "date" ,
},
{
Name : "FileHash" ,
SchemaName : "file_hash" ,
},
{
Name : "Secret" ,
SchemaName : "secret" ,
},
}
return typ
}
func (s *SecureFile ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureFile#7d09c27e as nil" )
}
b .PutID (SecureFileTypeID )
return s .EncodeBare (b )
}
func (s *SecureFile ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode secureFile#7d09c27e as nil" )
}
b .PutLong (s .ID )
b .PutLong (s .AccessHash )
b .PutLong (s .Size )
b .PutInt (s .DCID )
b .PutInt (s .Date )
b .PutBytes (s .FileHash )
b .PutBytes (s .Secret )
return nil
}
func (s *SecureFile ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureFile#7d09c27e to nil" )
}
if err := b .ConsumeID (SecureFileTypeID ); err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SecureFile ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode secureFile#7d09c27e to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: field id: %w" , err )
}
s .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: field access_hash: %w" , err )
}
s .AccessHash = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: field size: %w" , err )
}
s .Size = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: field dc_id: %w" , err )
}
s .DCID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: field date: %w" , err )
}
s .Date = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: field file_hash: %w" , err )
}
s .FileHash = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode secureFile#7d09c27e: field secret: %w" , err )
}
s .Secret = value
}
return nil
}
func (s *SecureFile ) GetID () (value int64 ) {
if s == nil {
return
}
return s .ID
}
func (s *SecureFile ) GetAccessHash () (value int64 ) {
if s == nil {
return
}
return s .AccessHash
}
func (s *SecureFile ) GetSize () (value int64 ) {
if s == nil {
return
}
return s .Size
}
func (s *SecureFile ) GetDCID () (value int ) {
if s == nil {
return
}
return s .DCID
}
func (s *SecureFile ) GetDate () (value int ) {
if s == nil {
return
}
return s .Date
}
func (s *SecureFile ) GetFileHash () (value []byte ) {
if s == nil {
return
}
return s .FileHash
}
func (s *SecureFile ) GetSecret () (value []byte ) {
if s == nil {
return
}
return s .Secret
}
const SecureFileClassName = "SecureFile"
type SecureFileClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () SecureFileClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*SecureFile , bool )
}
func (s *SecureFile ) AsInputSecureFileLocation () *InputSecureFileLocation {
value := new (InputSecureFileLocation )
value .ID = s .GetID ()
value .AccessHash = s .GetAccessHash ()
return value
}
func (s *SecureFile ) AsInput () *InputSecureFile {
value := new (InputSecureFile )
value .ID = s .GetID ()
value .AccessHash = s .GetAccessHash ()
return value
}
func (s *SecureFileEmpty ) AsNotEmpty () (*SecureFile , bool ) {
return nil , false
}
func (s *SecureFile ) AsNotEmpty () (*SecureFile , bool ) {
return s , true
}
func DecodeSecureFile (buf *bin .Buffer ) (SecureFileClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case SecureFileEmptyTypeID :
v := SecureFileEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SecureFileClass: %w" , err )
}
return &v , nil
case SecureFileTypeID :
v := SecureFile {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SecureFileClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode SecureFileClass: %w" , bin .NewUnexpectedID (id ))
}
}
type SecureFileBox struct {
SecureFile SecureFileClass
}
func (b *SecureFileBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode SecureFileBox to nil" )
}
v , err := DecodeSecureFile (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .SecureFile = v
return nil
}
func (b *SecureFileBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .SecureFile == nil {
return fmt .Errorf ("unable to encode SecureFileClass as nil" )
}
return b .SecureFile .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 .