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 InputTheme struct {
ID int64
AccessHash int64
}
const InputThemeTypeID = 0x3c5693e9
func (i InputTheme ) construct () InputThemeClass { return &i }
var (
_ bin .Encoder = &InputTheme {}
_ bin .Decoder = &InputTheme {}
_ bin .BareEncoder = &InputTheme {}
_ bin .BareDecoder = &InputTheme {}
_ InputThemeClass = &InputTheme {}
)
func (i *InputTheme ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
return true
}
func (i *InputTheme ) String () string {
if i == nil {
return "InputTheme(nil)"
}
type Alias InputTheme
return fmt .Sprintf ("InputTheme%+v" , Alias (*i ))
}
func (i *InputTheme ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
}) {
i .ID = from .GetID ()
i .AccessHash = from .GetAccessHash ()
}
func (*InputTheme ) TypeID () uint32 {
return InputThemeTypeID
}
func (*InputTheme ) TypeName () string {
return "inputTheme"
}
func (i *InputTheme ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputTheme" ,
ID : InputThemeTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
}
return typ
}
func (i *InputTheme ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputTheme#3c5693e9 as nil" )
}
b .PutID (InputThemeTypeID )
return i .EncodeBare (b )
}
func (i *InputTheme ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputTheme#3c5693e9 as nil" )
}
b .PutLong (i .ID )
b .PutLong (i .AccessHash )
return nil
}
func (i *InputTheme ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputTheme#3c5693e9 to nil" )
}
if err := b .ConsumeID (InputThemeTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputTheme#3c5693e9: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputTheme ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputTheme#3c5693e9 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputTheme#3c5693e9: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputTheme#3c5693e9: field access_hash: %w" , err )
}
i .AccessHash = value
}
return nil
}
func (i *InputTheme ) GetID () (value int64 ) {
if i == nil {
return
}
return i .ID
}
func (i *InputTheme ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
type InputThemeSlug struct {
Slug string
}
const InputThemeSlugTypeID = 0xf5890df1
func (i InputThemeSlug ) construct () InputThemeClass { return &i }
var (
_ bin .Encoder = &InputThemeSlug {}
_ bin .Decoder = &InputThemeSlug {}
_ bin .BareEncoder = &InputThemeSlug {}
_ bin .BareDecoder = &InputThemeSlug {}
_ InputThemeClass = &InputThemeSlug {}
)
func (i *InputThemeSlug ) Zero () bool {
if i == nil {
return true
}
if !(i .Slug == "" ) {
return false
}
return true
}
func (i *InputThemeSlug ) String () string {
if i == nil {
return "InputThemeSlug(nil)"
}
type Alias InputThemeSlug
return fmt .Sprintf ("InputThemeSlug%+v" , Alias (*i ))
}
func (i *InputThemeSlug ) FillFrom (from interface {
GetSlug () (value string )
}) {
i .Slug = from .GetSlug ()
}
func (*InputThemeSlug ) TypeID () uint32 {
return InputThemeSlugTypeID
}
func (*InputThemeSlug ) TypeName () string {
return "inputThemeSlug"
}
func (i *InputThemeSlug ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputThemeSlug" ,
ID : InputThemeSlugTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Slug" ,
SchemaName : "slug" ,
},
}
return typ
}
func (i *InputThemeSlug ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputThemeSlug#f5890df1 as nil" )
}
b .PutID (InputThemeSlugTypeID )
return i .EncodeBare (b )
}
func (i *InputThemeSlug ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputThemeSlug#f5890df1 as nil" )
}
b .PutString (i .Slug )
return nil
}
func (i *InputThemeSlug ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputThemeSlug#f5890df1 to nil" )
}
if err := b .ConsumeID (InputThemeSlugTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputThemeSlug#f5890df1: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputThemeSlug ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputThemeSlug#f5890df1 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputThemeSlug#f5890df1: field slug: %w" , err )
}
i .Slug = value
}
return nil
}
func (i *InputThemeSlug ) GetSlug () (value string ) {
if i == nil {
return
}
return i .Slug
}
const InputThemeClassName = "InputTheme"
type InputThemeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputThemeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputTheme (buf *bin .Buffer ) (InputThemeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputThemeTypeID :
v := InputTheme {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputThemeClass: %w" , err )
}
return &v , nil
case InputThemeSlugTypeID :
v := InputThemeSlug {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputThemeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputThemeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputThemeBox struct {
InputTheme InputThemeClass
}
func (b *InputThemeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputThemeBox to nil" )
}
v , err := DecodeInputTheme (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputTheme = v
return nil
}
func (b *InputThemeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputTheme == nil {
return fmt .Errorf ("unable to encode InputThemeClass as nil" )
}
return b .InputTheme .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 .