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 HelpTermsOfServiceUpdateEmpty struct {
Expires int
}
const HelpTermsOfServiceUpdateEmptyTypeID = 0xe3309f7f
func (t HelpTermsOfServiceUpdateEmpty ) construct () HelpTermsOfServiceUpdateClass { return &t }
var (
_ bin .Encoder = &HelpTermsOfServiceUpdateEmpty {}
_ bin .Decoder = &HelpTermsOfServiceUpdateEmpty {}
_ bin .BareEncoder = &HelpTermsOfServiceUpdateEmpty {}
_ bin .BareDecoder = &HelpTermsOfServiceUpdateEmpty {}
_ HelpTermsOfServiceUpdateClass = &HelpTermsOfServiceUpdateEmpty {}
)
func (t *HelpTermsOfServiceUpdateEmpty ) Zero () bool {
if t == nil {
return true
}
if !(t .Expires == 0 ) {
return false
}
return true
}
func (t *HelpTermsOfServiceUpdateEmpty ) String () string {
if t == nil {
return "HelpTermsOfServiceUpdateEmpty(nil)"
}
type Alias HelpTermsOfServiceUpdateEmpty
return fmt .Sprintf ("HelpTermsOfServiceUpdateEmpty%+v" , Alias (*t ))
}
func (t *HelpTermsOfServiceUpdateEmpty ) FillFrom (from interface {
GetExpires () (value int )
}) {
t .Expires = from .GetExpires ()
}
func (*HelpTermsOfServiceUpdateEmpty ) TypeID () uint32 {
return HelpTermsOfServiceUpdateEmptyTypeID
}
func (*HelpTermsOfServiceUpdateEmpty ) TypeName () string {
return "help.termsOfServiceUpdateEmpty"
}
func (t *HelpTermsOfServiceUpdateEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.termsOfServiceUpdateEmpty" ,
ID : HelpTermsOfServiceUpdateEmptyTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Expires" ,
SchemaName : "expires" ,
},
}
return typ
}
func (t *HelpTermsOfServiceUpdateEmpty ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode help.termsOfServiceUpdateEmpty#e3309f7f as nil" )
}
b .PutID (HelpTermsOfServiceUpdateEmptyTypeID )
return t .EncodeBare (b )
}
func (t *HelpTermsOfServiceUpdateEmpty ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode help.termsOfServiceUpdateEmpty#e3309f7f as nil" )
}
b .PutInt (t .Expires )
return nil
}
func (t *HelpTermsOfServiceUpdateEmpty ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode help.termsOfServiceUpdateEmpty#e3309f7f to nil" )
}
if err := b .ConsumeID (HelpTermsOfServiceUpdateEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.termsOfServiceUpdateEmpty#e3309f7f: %w" , err )
}
return t .DecodeBare (b )
}
func (t *HelpTermsOfServiceUpdateEmpty ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode help.termsOfServiceUpdateEmpty#e3309f7f to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.termsOfServiceUpdateEmpty#e3309f7f: field expires: %w" , err )
}
t .Expires = value
}
return nil
}
func (t *HelpTermsOfServiceUpdateEmpty ) GetExpires () (value int ) {
if t == nil {
return
}
return t .Expires
}
type HelpTermsOfServiceUpdate struct {
Expires int
TermsOfService HelpTermsOfService
}
const HelpTermsOfServiceUpdateTypeID = 0x28ecf961
func (t HelpTermsOfServiceUpdate ) construct () HelpTermsOfServiceUpdateClass { return &t }
var (
_ bin .Encoder = &HelpTermsOfServiceUpdate {}
_ bin .Decoder = &HelpTermsOfServiceUpdate {}
_ bin .BareEncoder = &HelpTermsOfServiceUpdate {}
_ bin .BareDecoder = &HelpTermsOfServiceUpdate {}
_ HelpTermsOfServiceUpdateClass = &HelpTermsOfServiceUpdate {}
)
func (t *HelpTermsOfServiceUpdate ) Zero () bool {
if t == nil {
return true
}
if !(t .Expires == 0 ) {
return false
}
if !(t .TermsOfService .Zero ()) {
return false
}
return true
}
func (t *HelpTermsOfServiceUpdate ) String () string {
if t == nil {
return "HelpTermsOfServiceUpdate(nil)"
}
type Alias HelpTermsOfServiceUpdate
return fmt .Sprintf ("HelpTermsOfServiceUpdate%+v" , Alias (*t ))
}
func (t *HelpTermsOfServiceUpdate ) FillFrom (from interface {
GetExpires () (value int )
GetTermsOfService () (value HelpTermsOfService )
}) {
t .Expires = from .GetExpires ()
t .TermsOfService = from .GetTermsOfService ()
}
func (*HelpTermsOfServiceUpdate ) TypeID () uint32 {
return HelpTermsOfServiceUpdateTypeID
}
func (*HelpTermsOfServiceUpdate ) TypeName () string {
return "help.termsOfServiceUpdate"
}
func (t *HelpTermsOfServiceUpdate ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.termsOfServiceUpdate" ,
ID : HelpTermsOfServiceUpdateTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Expires" ,
SchemaName : "expires" ,
},
{
Name : "TermsOfService" ,
SchemaName : "terms_of_service" ,
},
}
return typ
}
func (t *HelpTermsOfServiceUpdate ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode help.termsOfServiceUpdate#28ecf961 as nil" )
}
b .PutID (HelpTermsOfServiceUpdateTypeID )
return t .EncodeBare (b )
}
func (t *HelpTermsOfServiceUpdate ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode help.termsOfServiceUpdate#28ecf961 as nil" )
}
b .PutInt (t .Expires )
if err := t .TermsOfService .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.termsOfServiceUpdate#28ecf961: field terms_of_service: %w" , err )
}
return nil
}
func (t *HelpTermsOfServiceUpdate ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode help.termsOfServiceUpdate#28ecf961 to nil" )
}
if err := b .ConsumeID (HelpTermsOfServiceUpdateTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.termsOfServiceUpdate#28ecf961: %w" , err )
}
return t .DecodeBare (b )
}
func (t *HelpTermsOfServiceUpdate ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode help.termsOfServiceUpdate#28ecf961 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.termsOfServiceUpdate#28ecf961: field expires: %w" , err )
}
t .Expires = value
}
{
if err := t .TermsOfService .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.termsOfServiceUpdate#28ecf961: field terms_of_service: %w" , err )
}
}
return nil
}
func (t *HelpTermsOfServiceUpdate ) GetExpires () (value int ) {
if t == nil {
return
}
return t .Expires
}
func (t *HelpTermsOfServiceUpdate ) GetTermsOfService () (value HelpTermsOfService ) {
if t == nil {
return
}
return t .TermsOfService
}
const HelpTermsOfServiceUpdateClassName = "help.TermsOfServiceUpdate"
type HelpTermsOfServiceUpdateClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () HelpTermsOfServiceUpdateClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetExpires () (value int )
AsNotEmpty () (*HelpTermsOfServiceUpdate , bool )
}
func (t *HelpTermsOfServiceUpdateEmpty ) AsNotEmpty () (*HelpTermsOfServiceUpdate , bool ) {
return nil , false
}
func (t *HelpTermsOfServiceUpdate ) AsNotEmpty () (*HelpTermsOfServiceUpdate , bool ) {
return t , true
}
func DecodeHelpTermsOfServiceUpdate (buf *bin .Buffer ) (HelpTermsOfServiceUpdateClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case HelpTermsOfServiceUpdateEmptyTypeID :
v := HelpTermsOfServiceUpdateEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpTermsOfServiceUpdateClass: %w" , err )
}
return &v , nil
case HelpTermsOfServiceUpdateTypeID :
v := HelpTermsOfServiceUpdate {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpTermsOfServiceUpdateClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode HelpTermsOfServiceUpdateClass: %w" , bin .NewUnexpectedID (id ))
}
}
type HelpTermsOfServiceUpdateBox struct {
TermsOfServiceUpdate HelpTermsOfServiceUpdateClass
}
func (b *HelpTermsOfServiceUpdateBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode HelpTermsOfServiceUpdateBox to nil" )
}
v , err := DecodeHelpTermsOfServiceUpdate (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .TermsOfServiceUpdate = v
return nil
}
func (b *HelpTermsOfServiceUpdateBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .TermsOfServiceUpdate == nil {
return fmt .Errorf ("unable to encode HelpTermsOfServiceUpdateClass as nil" )
}
return b .TermsOfServiceUpdate .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 .