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 HelpCountryCode struct {
Flags bin .Fields
CountryCode string
Prefixes []string
Patterns []string
}
const HelpCountryCodeTypeID = 0x4203c5ef
var (
_ bin .Encoder = &HelpCountryCode {}
_ bin .Decoder = &HelpCountryCode {}
_ bin .BareEncoder = &HelpCountryCode {}
_ bin .BareDecoder = &HelpCountryCode {}
)
func (c *HelpCountryCode ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .CountryCode == "" ) {
return false
}
if !(c .Prefixes == nil ) {
return false
}
if !(c .Patterns == nil ) {
return false
}
return true
}
func (c *HelpCountryCode ) String () string {
if c == nil {
return "HelpCountryCode(nil)"
}
type Alias HelpCountryCode
return fmt .Sprintf ("HelpCountryCode%+v" , Alias (*c ))
}
func (c *HelpCountryCode ) FillFrom (from interface {
GetCountryCode () (value string )
GetPrefixes () (value []string , ok bool )
GetPatterns () (value []string , ok bool )
}) {
c .CountryCode = from .GetCountryCode ()
if val , ok := from .GetPrefixes (); ok {
c .Prefixes = val
}
if val , ok := from .GetPatterns (); ok {
c .Patterns = val
}
}
func (*HelpCountryCode ) TypeID () uint32 {
return HelpCountryCodeTypeID
}
func (*HelpCountryCode ) TypeName () string {
return "help.countryCode"
}
func (c *HelpCountryCode ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.countryCode" ,
ID : HelpCountryCodeTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CountryCode" ,
SchemaName : "country_code" ,
},
{
Name : "Prefixes" ,
SchemaName : "prefixes" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Patterns" ,
SchemaName : "patterns" ,
Null : !c .Flags .Has (1 ),
},
}
return typ
}
func (c *HelpCountryCode ) SetFlags () {
if !(c .Prefixes == nil ) {
c .Flags .Set (0 )
}
if !(c .Patterns == nil ) {
c .Flags .Set (1 )
}
}
func (c *HelpCountryCode ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.countryCode#4203c5ef as nil" )
}
b .PutID (HelpCountryCodeTypeID )
return c .EncodeBare (b )
}
func (c *HelpCountryCode ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.countryCode#4203c5ef as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.countryCode#4203c5ef: field flags: %w" , err )
}
b .PutString (c .CountryCode )
if c .Flags .Has (0 ) {
b .PutVectorHeader (len (c .Prefixes ))
for _ , v := range c .Prefixes {
b .PutString (v )
}
}
if c .Flags .Has (1 ) {
b .PutVectorHeader (len (c .Patterns ))
for _ , v := range c .Patterns {
b .PutString (v )
}
}
return nil
}
func (c *HelpCountryCode ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.countryCode#4203c5ef to nil" )
}
if err := b .ConsumeID (HelpCountryCodeTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.countryCode#4203c5ef: %w" , err )
}
return c .DecodeBare (b )
}
func (c *HelpCountryCode ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.countryCode#4203c5ef to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.countryCode#4203c5ef: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.countryCode#4203c5ef: field country_code: %w" , err )
}
c .CountryCode = value
}
if c .Flags .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.countryCode#4203c5ef: field prefixes: %w" , err )
}
if headerLen > 0 {
c .Prefixes = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.countryCode#4203c5ef: field prefixes: %w" , err )
}
c .Prefixes = append (c .Prefixes , value )
}
}
if c .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.countryCode#4203c5ef: field patterns: %w" , err )
}
if headerLen > 0 {
c .Patterns = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.countryCode#4203c5ef: field patterns: %w" , err )
}
c .Patterns = append (c .Patterns , value )
}
}
return nil
}
func (c *HelpCountryCode ) GetCountryCode () (value string ) {
if c == nil {
return
}
return c .CountryCode
}
func (c *HelpCountryCode ) SetPrefixes (value []string ) {
c .Flags .Set (0 )
c .Prefixes = value
}
func (c *HelpCountryCode ) GetPrefixes () (value []string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .Prefixes , true
}
func (c *HelpCountryCode ) SetPatterns (value []string ) {
c .Flags .Set (1 )
c .Patterns = value
}
func (c *HelpCountryCode ) GetPatterns () (value []string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .Patterns , true
}
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 .