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 KeyboardButtonRow struct {
Buttons []KeyboardButtonClass
}
const KeyboardButtonRowTypeID = 0x77608b83
var (
_ bin .Encoder = &KeyboardButtonRow {}
_ bin .Decoder = &KeyboardButtonRow {}
_ bin .BareEncoder = &KeyboardButtonRow {}
_ bin .BareDecoder = &KeyboardButtonRow {}
)
func (k *KeyboardButtonRow ) Zero () bool {
if k == nil {
return true
}
if !(k .Buttons == nil ) {
return false
}
return true
}
func (k *KeyboardButtonRow ) String () string {
if k == nil {
return "KeyboardButtonRow(nil)"
}
type Alias KeyboardButtonRow
return fmt .Sprintf ("KeyboardButtonRow%+v" , Alias (*k ))
}
func (k *KeyboardButtonRow ) FillFrom (from interface {
GetButtons () (value []KeyboardButtonClass )
}) {
k .Buttons = from .GetButtons ()
}
func (*KeyboardButtonRow ) TypeID () uint32 {
return KeyboardButtonRowTypeID
}
func (*KeyboardButtonRow ) TypeName () string {
return "keyboardButtonRow"
}
func (k *KeyboardButtonRow ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "keyboardButtonRow" ,
ID : KeyboardButtonRowTypeID ,
}
if k == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Buttons" ,
SchemaName : "buttons" ,
},
}
return typ
}
func (k *KeyboardButtonRow ) Encode (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't encode keyboardButtonRow#77608b83 as nil" )
}
b .PutID (KeyboardButtonRowTypeID )
return k .EncodeBare (b )
}
func (k *KeyboardButtonRow ) EncodeBare (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't encode keyboardButtonRow#77608b83 as nil" )
}
b .PutVectorHeader (len (k .Buttons ))
for idx , v := range k .Buttons {
if v == nil {
return fmt .Errorf ("unable to encode keyboardButtonRow#77608b83: field buttons element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode keyboardButtonRow#77608b83: field buttons element with index %d: %w" , idx , err )
}
}
return nil
}
func (k *KeyboardButtonRow ) Decode (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't decode keyboardButtonRow#77608b83 to nil" )
}
if err := b .ConsumeID (KeyboardButtonRowTypeID ); err != nil {
return fmt .Errorf ("unable to decode keyboardButtonRow#77608b83: %w" , err )
}
return k .DecodeBare (b )
}
func (k *KeyboardButtonRow ) DecodeBare (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't decode keyboardButtonRow#77608b83 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode keyboardButtonRow#77608b83: field buttons: %w" , err )
}
if headerLen > 0 {
k .Buttons = make ([]KeyboardButtonClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeKeyboardButton (b )
if err != nil {
return fmt .Errorf ("unable to decode keyboardButtonRow#77608b83: field buttons: %w" , err )
}
k .Buttons = append (k .Buttons , value )
}
}
return nil
}
func (k *KeyboardButtonRow ) GetButtons () (value []KeyboardButtonClass ) {
if k == nil {
return
}
return k .Buttons
}
func (k *KeyboardButtonRow ) MapButtons () (value KeyboardButtonClassArray ) {
return KeyboardButtonClassArray (k .Buttons )
}
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 .