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 HelpConfigSimple struct {
Date int
Expires int
Rules []AccessPointRule
}
const HelpConfigSimpleTypeID = 0x5a592a6c
var (
_ bin .Encoder = &HelpConfigSimple {}
_ bin .Decoder = &HelpConfigSimple {}
_ bin .BareEncoder = &HelpConfigSimple {}
_ bin .BareDecoder = &HelpConfigSimple {}
)
func (c *HelpConfigSimple ) Zero () bool {
if c == nil {
return true
}
if !(c .Date == 0 ) {
return false
}
if !(c .Expires == 0 ) {
return false
}
if !(c .Rules == nil ) {
return false
}
return true
}
func (c *HelpConfigSimple ) String () string {
if c == nil {
return "HelpConfigSimple(nil)"
}
type Alias HelpConfigSimple
return fmt .Sprintf ("HelpConfigSimple%+v" , Alias (*c ))
}
func (c *HelpConfigSimple ) FillFrom (from interface {
GetDate () (value int )
GetExpires () (value int )
GetRules () (value []AccessPointRule )
}) {
c .Date = from .GetDate ()
c .Expires = from .GetExpires ()
c .Rules = from .GetRules ()
}
func (*HelpConfigSimple ) TypeID () uint32 {
return HelpConfigSimpleTypeID
}
func (*HelpConfigSimple ) TypeName () string {
return "help.configSimple"
}
func (c *HelpConfigSimple ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.configSimple" ,
ID : HelpConfigSimpleTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Expires" ,
SchemaName : "expires" ,
},
{
Name : "Rules" ,
SchemaName : "rules" ,
},
}
return typ
}
func (c *HelpConfigSimple ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.configSimple#5a592a6c as nil" )
}
b .PutID (HelpConfigSimpleTypeID )
return c .EncodeBare (b )
}
func (c *HelpConfigSimple ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode help.configSimple#5a592a6c as nil" )
}
b .PutInt (c .Date )
b .PutInt (c .Expires )
b .PutInt (len (c .Rules ))
for idx , v := range c .Rules {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.configSimple#5a592a6c: field rules element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *HelpConfigSimple ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.configSimple#5a592a6c to nil" )
}
if err := b .ConsumeID (HelpConfigSimpleTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.configSimple#5a592a6c: %w" , err )
}
return c .DecodeBare (b )
}
func (c *HelpConfigSimple ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode help.configSimple#5a592a6c to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.configSimple#5a592a6c: field date: %w" , err )
}
c .Date = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.configSimple#5a592a6c: field expires: %w" , err )
}
c .Expires = value
}
{
headerLen , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.configSimple#5a592a6c: field rules: %w" , err )
}
if headerLen > 0 {
c .Rules = make ([]AccessPointRule , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value AccessPointRule
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.configSimple#5a592a6c: field rules: %w" , err )
}
c .Rules = append (c .Rules , value )
}
}
return nil
}
func (c *HelpConfigSimple ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
func (c *HelpConfigSimple ) GetExpires () (value int ) {
if c == nil {
return
}
return c .Expires
}
func (c *HelpConfigSimple ) GetRules () (value []AccessPointRule ) {
if c == nil {
return
}
return c .Rules
}
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 .