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 InputPhotoEmpty struct {
}
const InputPhotoEmptyTypeID = 0x1cd7bf0d
func (i InputPhotoEmpty ) construct () InputPhotoClass { return &i }
var (
_ bin .Encoder = &InputPhotoEmpty {}
_ bin .Decoder = &InputPhotoEmpty {}
_ bin .BareEncoder = &InputPhotoEmpty {}
_ bin .BareDecoder = &InputPhotoEmpty {}
_ InputPhotoClass = &InputPhotoEmpty {}
)
func (i *InputPhotoEmpty ) Zero () bool {
if i == nil {
return true
}
return true
}
func (i *InputPhotoEmpty ) String () string {
if i == nil {
return "InputPhotoEmpty(nil)"
}
type Alias InputPhotoEmpty
return fmt .Sprintf ("InputPhotoEmpty%+v" , Alias (*i ))
}
func (*InputPhotoEmpty ) TypeID () uint32 {
return InputPhotoEmptyTypeID
}
func (*InputPhotoEmpty ) TypeName () string {
return "inputPhotoEmpty"
}
func (i *InputPhotoEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPhotoEmpty" ,
ID : InputPhotoEmptyTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (i *InputPhotoEmpty ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPhotoEmpty#1cd7bf0d as nil" )
}
b .PutID (InputPhotoEmptyTypeID )
return i .EncodeBare (b )
}
func (i *InputPhotoEmpty ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPhotoEmpty#1cd7bf0d as nil" )
}
return nil
}
func (i *InputPhotoEmpty ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPhotoEmpty#1cd7bf0d to nil" )
}
if err := b .ConsumeID (InputPhotoEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPhotoEmpty#1cd7bf0d: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPhotoEmpty ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPhotoEmpty#1cd7bf0d to nil" )
}
return nil
}
type InputPhoto struct {
ID int64
AccessHash int64
FileReference []byte
}
const InputPhotoTypeID = 0x3bb3b94a
func (i InputPhoto ) construct () InputPhotoClass { return &i }
var (
_ bin .Encoder = &InputPhoto {}
_ bin .Decoder = &InputPhoto {}
_ bin .BareEncoder = &InputPhoto {}
_ bin .BareDecoder = &InputPhoto {}
_ InputPhotoClass = &InputPhoto {}
)
func (i *InputPhoto ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
if !(i .FileReference == nil ) {
return false
}
return true
}
func (i *InputPhoto ) String () string {
if i == nil {
return "InputPhoto(nil)"
}
type Alias InputPhoto
return fmt .Sprintf ("InputPhoto%+v" , Alias (*i ))
}
func (i *InputPhoto ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
GetFileReference () (value []byte )
}) {
i .ID = from .GetID ()
i .AccessHash = from .GetAccessHash ()
i .FileReference = from .GetFileReference ()
}
func (*InputPhoto ) TypeID () uint32 {
return InputPhotoTypeID
}
func (*InputPhoto ) TypeName () string {
return "inputPhoto"
}
func (i *InputPhoto ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPhoto" ,
ID : InputPhotoTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "FileReference" ,
SchemaName : "file_reference" ,
},
}
return typ
}
func (i *InputPhoto ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPhoto#3bb3b94a as nil" )
}
b .PutID (InputPhotoTypeID )
return i .EncodeBare (b )
}
func (i *InputPhoto ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPhoto#3bb3b94a as nil" )
}
b .PutLong (i .ID )
b .PutLong (i .AccessHash )
b .PutBytes (i .FileReference )
return nil
}
func (i *InputPhoto ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPhoto#3bb3b94a to nil" )
}
if err := b .ConsumeID (InputPhotoTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPhoto#3bb3b94a: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPhoto ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPhoto#3bb3b94a to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputPhoto#3bb3b94a: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputPhoto#3bb3b94a: field access_hash: %w" , err )
}
i .AccessHash = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode inputPhoto#3bb3b94a: field file_reference: %w" , err )
}
i .FileReference = value
}
return nil
}
func (i *InputPhoto ) GetID () (value int64 ) {
if i == nil {
return
}
return i .ID
}
func (i *InputPhoto ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
func (i *InputPhoto ) GetFileReference () (value []byte ) {
if i == nil {
return
}
return i .FileReference
}
const InputPhotoClassName = "InputPhoto"
type InputPhotoClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputPhotoClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*InputPhoto , bool )
}
func (i *InputPhotoEmpty ) AsNotEmpty () (*InputPhoto , bool ) {
return nil , false
}
func (i *InputPhoto ) AsNotEmpty () (*InputPhoto , bool ) {
return i , true
}
func DecodeInputPhoto (buf *bin .Buffer ) (InputPhotoClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputPhotoEmptyTypeID :
v := InputPhotoEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputPhotoClass: %w" , err )
}
return &v , nil
case InputPhotoTypeID :
v := InputPhoto {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputPhotoClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputPhotoClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputPhotoBox struct {
InputPhoto InputPhotoClass
}
func (b *InputPhotoBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputPhotoBox to nil" )
}
v , err := DecodeInputPhoto (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputPhoto = v
return nil
}
func (b *InputPhotoBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputPhoto == nil {
return fmt .Errorf ("unable to encode InputPhotoClass as nil" )
}
return b .InputPhoto .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 .