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 InputCollectibleUsername struct {
Username string
}
const InputCollectibleUsernameTypeID = 0xe39460a9
func (i InputCollectibleUsername ) construct () InputCollectibleClass { return &i }
var (
_ bin .Encoder = &InputCollectibleUsername {}
_ bin .Decoder = &InputCollectibleUsername {}
_ bin .BareEncoder = &InputCollectibleUsername {}
_ bin .BareDecoder = &InputCollectibleUsername {}
_ InputCollectibleClass = &InputCollectibleUsername {}
)
func (i *InputCollectibleUsername ) Zero () bool {
if i == nil {
return true
}
if !(i .Username == "" ) {
return false
}
return true
}
func (i *InputCollectibleUsername ) String () string {
if i == nil {
return "InputCollectibleUsername(nil)"
}
type Alias InputCollectibleUsername
return fmt .Sprintf ("InputCollectibleUsername%+v" , Alias (*i ))
}
func (i *InputCollectibleUsername ) FillFrom (from interface {
GetUsername () (value string )
}) {
i .Username = from .GetUsername ()
}
func (*InputCollectibleUsername ) TypeID () uint32 {
return InputCollectibleUsernameTypeID
}
func (*InputCollectibleUsername ) TypeName () string {
return "inputCollectibleUsername"
}
func (i *InputCollectibleUsername ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputCollectibleUsername" ,
ID : InputCollectibleUsernameTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Username" ,
SchemaName : "username" ,
},
}
return typ
}
func (i *InputCollectibleUsername ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputCollectibleUsername#e39460a9 as nil" )
}
b .PutID (InputCollectibleUsernameTypeID )
return i .EncodeBare (b )
}
func (i *InputCollectibleUsername ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputCollectibleUsername#e39460a9 as nil" )
}
b .PutString (i .Username )
return nil
}
func (i *InputCollectibleUsername ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputCollectibleUsername#e39460a9 to nil" )
}
if err := b .ConsumeID (InputCollectibleUsernameTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputCollectibleUsername#e39460a9: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputCollectibleUsername ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputCollectibleUsername#e39460a9 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputCollectibleUsername#e39460a9: field username: %w" , err )
}
i .Username = value
}
return nil
}
func (i *InputCollectibleUsername ) GetUsername () (value string ) {
if i == nil {
return
}
return i .Username
}
type InputCollectiblePhone struct {
Phone string
}
const InputCollectiblePhoneTypeID = 0xa2e214a4
func (i InputCollectiblePhone ) construct () InputCollectibleClass { return &i }
var (
_ bin .Encoder = &InputCollectiblePhone {}
_ bin .Decoder = &InputCollectiblePhone {}
_ bin .BareEncoder = &InputCollectiblePhone {}
_ bin .BareDecoder = &InputCollectiblePhone {}
_ InputCollectibleClass = &InputCollectiblePhone {}
)
func (i *InputCollectiblePhone ) Zero () bool {
if i == nil {
return true
}
if !(i .Phone == "" ) {
return false
}
return true
}
func (i *InputCollectiblePhone ) String () string {
if i == nil {
return "InputCollectiblePhone(nil)"
}
type Alias InputCollectiblePhone
return fmt .Sprintf ("InputCollectiblePhone%+v" , Alias (*i ))
}
func (i *InputCollectiblePhone ) FillFrom (from interface {
GetPhone () (value string )
}) {
i .Phone = from .GetPhone ()
}
func (*InputCollectiblePhone ) TypeID () uint32 {
return InputCollectiblePhoneTypeID
}
func (*InputCollectiblePhone ) TypeName () string {
return "inputCollectiblePhone"
}
func (i *InputCollectiblePhone ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputCollectiblePhone" ,
ID : InputCollectiblePhoneTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Phone" ,
SchemaName : "phone" ,
},
}
return typ
}
func (i *InputCollectiblePhone ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputCollectiblePhone#a2e214a4 as nil" )
}
b .PutID (InputCollectiblePhoneTypeID )
return i .EncodeBare (b )
}
func (i *InputCollectiblePhone ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputCollectiblePhone#a2e214a4 as nil" )
}
b .PutString (i .Phone )
return nil
}
func (i *InputCollectiblePhone ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputCollectiblePhone#a2e214a4 to nil" )
}
if err := b .ConsumeID (InputCollectiblePhoneTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputCollectiblePhone#a2e214a4: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputCollectiblePhone ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputCollectiblePhone#a2e214a4 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputCollectiblePhone#a2e214a4: field phone: %w" , err )
}
i .Phone = value
}
return nil
}
func (i *InputCollectiblePhone ) GetPhone () (value string ) {
if i == nil {
return
}
return i .Phone
}
const InputCollectibleClassName = "InputCollectible"
type InputCollectibleClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputCollectibleClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputCollectible (buf *bin .Buffer ) (InputCollectibleClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputCollectibleUsernameTypeID :
v := InputCollectibleUsername {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputCollectibleClass: %w" , err )
}
return &v , nil
case InputCollectiblePhoneTypeID :
v := InputCollectiblePhone {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputCollectibleClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputCollectibleClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputCollectibleBox struct {
InputCollectible InputCollectibleClass
}
func (b *InputCollectibleBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputCollectibleBox to nil" )
}
v , err := DecodeInputCollectible (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputCollectible = v
return nil
}
func (b *InputCollectibleBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputCollectible == nil {
return fmt .Errorf ("unable to encode InputCollectibleClass as nil" )
}
return b .InputCollectible .Encode (buf )
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .