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 HelpCountriesListNotModified struct {
}
const HelpCountriesListNotModifiedTypeID = 0x93cc1f32
func (c HelpCountriesListNotModified ) construct () HelpCountriesListClass { return &c }
var (
_ bin .Encoder = &HelpCountriesListNotModified {}
_ bin .Decoder = &HelpCountriesListNotModified {}
_ bin .BareEncoder = &HelpCountriesListNotModified {}
_ bin .BareDecoder = &HelpCountriesListNotModified {}
_ HelpCountriesListClass = &HelpCountriesListNotModified {}
)
func (c *HelpCountriesListNotModified ) Zero () bool {
if c == nil {
return true
}
return true
}
func (c *HelpCountriesListNotModified ) String () string {
if c == nil {
return "HelpCountriesListNotModified(nil)"
}
type Alias HelpCountriesListNotModified
return fmt .Sprintf ("HelpCountriesListNotModified%+v" , Alias (*c ))
}
func (*HelpCountriesListNotModified ) TypeID () uint32 {
return HelpCountriesListNotModifiedTypeID
}
func (*HelpCountriesListNotModified ) TypeName () string {
return "help.countriesListNotModified"
}
func (c *HelpCountriesListNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.countriesListNotModified" ,
ID : HelpCountriesListNotModifiedTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (c *HelpCountriesListNotModified ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.countriesListNotModified#93cc1f32 as nil" )
}
b .PutID (HelpCountriesListNotModifiedTypeID )
return c .EncodeBare (b )
}
func (c *HelpCountriesListNotModified ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.countriesListNotModified#93cc1f32 as nil" )
}
return nil
}
func (c *HelpCountriesListNotModified ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.countriesListNotModified#93cc1f32 to nil" )
}
if err := b .ConsumeID (HelpCountriesListNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.countriesListNotModified#93cc1f32: %w" , err )
}
return c .DecodeBare (b )
}
func (c *HelpCountriesListNotModified ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.countriesListNotModified#93cc1f32 to nil" )
}
return nil
}
type HelpCountriesList struct {
Countries []HelpCountry
Hash int
}
const HelpCountriesListTypeID = 0x87d0759e
func (c HelpCountriesList ) construct () HelpCountriesListClass { return &c }
var (
_ bin .Encoder = &HelpCountriesList {}
_ bin .Decoder = &HelpCountriesList {}
_ bin .BareEncoder = &HelpCountriesList {}
_ bin .BareDecoder = &HelpCountriesList {}
_ HelpCountriesListClass = &HelpCountriesList {}
)
func (c *HelpCountriesList ) Zero () bool {
if c == nil {
return true
}
if !(c .Countries == nil ) {
return false
}
if !(c .Hash == 0 ) {
return false
}
return true
}
func (c *HelpCountriesList ) String () string {
if c == nil {
return "HelpCountriesList(nil)"
}
type Alias HelpCountriesList
return fmt .Sprintf ("HelpCountriesList%+v" , Alias (*c ))
}
func (c *HelpCountriesList ) FillFrom (from interface {
GetCountries () (value []HelpCountry )
GetHash () (value int )
}) {
c .Countries = from .GetCountries ()
c .Hash = from .GetHash ()
}
func (*HelpCountriesList ) TypeID () uint32 {
return HelpCountriesListTypeID
}
func (*HelpCountriesList ) TypeName () string {
return "help.countriesList"
}
func (c *HelpCountriesList ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.countriesList" ,
ID : HelpCountriesListTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Countries" ,
SchemaName : "countries" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (c *HelpCountriesList ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.countriesList#87d0759e as nil" )
}
b .PutID (HelpCountriesListTypeID )
return c .EncodeBare (b )
}
func (c *HelpCountriesList ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.countriesList#87d0759e as nil" )
}
b .PutVectorHeader (len (c .Countries ))
for idx , v := range c .Countries {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.countriesList#87d0759e: field countries element with index %d: %w" , idx , err )
}
}
b .PutInt (c .Hash )
return nil
}
func (c *HelpCountriesList ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.countriesList#87d0759e to nil" )
}
if err := b .ConsumeID (HelpCountriesListTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.countriesList#87d0759e: %w" , err )
}
return c .DecodeBare (b )
}
func (c *HelpCountriesList ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.countriesList#87d0759e to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.countriesList#87d0759e: field countries: %w" , err )
}
if headerLen > 0 {
c .Countries = make ([]HelpCountry , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value HelpCountry
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.countriesList#87d0759e: field countries: %w" , err )
}
c .Countries = append (c .Countries , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.countriesList#87d0759e: field hash: %w" , err )
}
c .Hash = value
}
return nil
}
func (c *HelpCountriesList ) GetCountries () (value []HelpCountry ) {
if c == nil {
return
}
return c .Countries
}
func (c *HelpCountriesList ) GetHash () (value int ) {
if c == nil {
return
}
return c .Hash
}
const HelpCountriesListClassName = "help.CountriesList"
type HelpCountriesListClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () HelpCountriesListClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*HelpCountriesList , bool )
}
func (c *HelpCountriesListNotModified ) AsModified () (*HelpCountriesList , bool ) {
return nil , false
}
func (c *HelpCountriesList ) AsModified () (*HelpCountriesList , bool ) {
return c , true
}
func DecodeHelpCountriesList (buf *bin .Buffer ) (HelpCountriesListClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case HelpCountriesListNotModifiedTypeID :
v := HelpCountriesListNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpCountriesListClass: %w" , err )
}
return &v , nil
case HelpCountriesListTypeID :
v := HelpCountriesList {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpCountriesListClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode HelpCountriesListClass: %w" , bin .NewUnexpectedID (id ))
}
}
type HelpCountriesListBox struct {
CountriesList HelpCountriesListClass
}
func (b *HelpCountriesListBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode HelpCountriesListBox to nil" )
}
v , err := DecodeHelpCountriesList (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .CountriesList = v
return nil
}
func (b *HelpCountriesListBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .CountriesList == nil {
return fmt .Errorf ("unable to encode HelpCountriesListClass as nil" )
}
return b .CountriesList .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 .