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 PageListItemText struct {
Text RichTextClass
}
const PageListItemTextTypeID = 0xb92fb6cd
func (p PageListItemText ) construct () PageListItemClass { return &p }
var (
_ bin .Encoder = &PageListItemText {}
_ bin .Decoder = &PageListItemText {}
_ bin .BareEncoder = &PageListItemText {}
_ bin .BareDecoder = &PageListItemText {}
_ PageListItemClass = &PageListItemText {}
)
func (p *PageListItemText ) Zero () bool {
if p == nil {
return true
}
if !(p .Text == nil ) {
return false
}
return true
}
func (p *PageListItemText ) String () string {
if p == nil {
return "PageListItemText(nil)"
}
type Alias PageListItemText
return fmt .Sprintf ("PageListItemText%+v" , Alias (*p ))
}
func (p *PageListItemText ) FillFrom (from interface {
GetText () (value RichTextClass )
}) {
p .Text = from .GetText ()
}
func (*PageListItemText ) TypeID () uint32 {
return PageListItemTextTypeID
}
func (*PageListItemText ) TypeName () string {
return "pageListItemText"
}
func (p *PageListItemText ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "pageListItemText" ,
ID : PageListItemTextTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Text" ,
SchemaName : "text" ,
},
}
return typ
}
func (p *PageListItemText ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListItemText#b92fb6cd as nil" )
}
b .PutID (PageListItemTextTypeID )
return p .EncodeBare (b )
}
func (p *PageListItemText ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListItemText#b92fb6cd as nil" )
}
if p .Text == nil {
return fmt .Errorf ("unable to encode pageListItemText#b92fb6cd: field text is nil" )
}
if err := p .Text .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageListItemText#b92fb6cd: field text: %w" , err )
}
return nil
}
func (p *PageListItemText ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListItemText#b92fb6cd to nil" )
}
if err := b .ConsumeID (PageListItemTextTypeID ); err != nil {
return fmt .Errorf ("unable to decode pageListItemText#b92fb6cd: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PageListItemText ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListItemText#b92fb6cd to nil" )
}
{
value , err := DecodeRichText (b )
if err != nil {
return fmt .Errorf ("unable to decode pageListItemText#b92fb6cd: field text: %w" , err )
}
p .Text = value
}
return nil
}
func (p *PageListItemText ) GetText () (value RichTextClass ) {
if p == nil {
return
}
return p .Text
}
type PageListItemBlocks struct {
Blocks []PageBlockClass
}
const PageListItemBlocksTypeID = 0x25e073fc
func (p PageListItemBlocks ) construct () PageListItemClass { return &p }
var (
_ bin .Encoder = &PageListItemBlocks {}
_ bin .Decoder = &PageListItemBlocks {}
_ bin .BareEncoder = &PageListItemBlocks {}
_ bin .BareDecoder = &PageListItemBlocks {}
_ PageListItemClass = &PageListItemBlocks {}
)
func (p *PageListItemBlocks ) Zero () bool {
if p == nil {
return true
}
if !(p .Blocks == nil ) {
return false
}
return true
}
func (p *PageListItemBlocks ) String () string {
if p == nil {
return "PageListItemBlocks(nil)"
}
type Alias PageListItemBlocks
return fmt .Sprintf ("PageListItemBlocks%+v" , Alias (*p ))
}
func (p *PageListItemBlocks ) FillFrom (from interface {
GetBlocks () (value []PageBlockClass )
}) {
p .Blocks = from .GetBlocks ()
}
func (*PageListItemBlocks ) TypeID () uint32 {
return PageListItemBlocksTypeID
}
func (*PageListItemBlocks ) TypeName () string {
return "pageListItemBlocks"
}
func (p *PageListItemBlocks ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "pageListItemBlocks" ,
ID : PageListItemBlocksTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Blocks" ,
SchemaName : "blocks" ,
},
}
return typ
}
func (p *PageListItemBlocks ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListItemBlocks#25e073fc as nil" )
}
b .PutID (PageListItemBlocksTypeID )
return p .EncodeBare (b )
}
func (p *PageListItemBlocks ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListItemBlocks#25e073fc as nil" )
}
b .PutVectorHeader (len (p .Blocks ))
for idx , v := range p .Blocks {
if v == nil {
return fmt .Errorf ("unable to encode pageListItemBlocks#25e073fc: field blocks element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageListItemBlocks#25e073fc: field blocks element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *PageListItemBlocks ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListItemBlocks#25e073fc to nil" )
}
if err := b .ConsumeID (PageListItemBlocksTypeID ); err != nil {
return fmt .Errorf ("unable to decode pageListItemBlocks#25e073fc: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PageListItemBlocks ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListItemBlocks#25e073fc to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode pageListItemBlocks#25e073fc: field blocks: %w" , err )
}
if headerLen > 0 {
p .Blocks = make ([]PageBlockClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodePageBlock (b )
if err != nil {
return fmt .Errorf ("unable to decode pageListItemBlocks#25e073fc: field blocks: %w" , err )
}
p .Blocks = append (p .Blocks , value )
}
}
return nil
}
func (p *PageListItemBlocks ) GetBlocks () (value []PageBlockClass ) {
if p == nil {
return
}
return p .Blocks
}
func (p *PageListItemBlocks ) MapBlocks () (value PageBlockClassArray ) {
return PageBlockClassArray (p .Blocks )
}
const PageListItemClassName = "PageListItem"
type PageListItemClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PageListItemClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodePageListItem (buf *bin .Buffer ) (PageListItemClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PageListItemTextTypeID :
v := PageListItemText {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PageListItemClass: %w" , err )
}
return &v , nil
case PageListItemBlocksTypeID :
v := PageListItemBlocks {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PageListItemClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PageListItemClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PageListItemBox struct {
PageListItem PageListItemClass
}
func (b *PageListItemBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PageListItemBox to nil" )
}
v , err := DecodePageListItem (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .PageListItem = v
return nil
}
func (b *PageListItemBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .PageListItem == nil {
return fmt .Errorf ("unable to encode PageListItemClass as nil" )
}
return b .PageListItem .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 .