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 PageListOrderedItemText struct {
Num string
Text RichTextClass
}
const PageListOrderedItemTextTypeID = 0x5e068047
func (p PageListOrderedItemText ) construct () PageListOrderedItemClass { return &p }
var (
_ bin .Encoder = &PageListOrderedItemText {}
_ bin .Decoder = &PageListOrderedItemText {}
_ bin .BareEncoder = &PageListOrderedItemText {}
_ bin .BareDecoder = &PageListOrderedItemText {}
_ PageListOrderedItemClass = &PageListOrderedItemText {}
)
func (p *PageListOrderedItemText ) Zero () bool {
if p == nil {
return true
}
if !(p .Num == "" ) {
return false
}
if !(p .Text == nil ) {
return false
}
return true
}
func (p *PageListOrderedItemText ) String () string {
if p == nil {
return "PageListOrderedItemText(nil)"
}
type Alias PageListOrderedItemText
return fmt .Sprintf ("PageListOrderedItemText%+v" , Alias (*p ))
}
func (p *PageListOrderedItemText ) FillFrom (from interface {
GetNum () (value string )
GetText () (value RichTextClass )
}) {
p .Num = from .GetNum ()
p .Text = from .GetText ()
}
func (*PageListOrderedItemText ) TypeID () uint32 {
return PageListOrderedItemTextTypeID
}
func (*PageListOrderedItemText ) TypeName () string {
return "pageListOrderedItemText"
}
func (p *PageListOrderedItemText ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "pageListOrderedItemText" ,
ID : PageListOrderedItemTextTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Num" ,
SchemaName : "num" ,
},
{
Name : "Text" ,
SchemaName : "text" ,
},
}
return typ
}
func (p *PageListOrderedItemText ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListOrderedItemText#5e068047 as nil" )
}
b .PutID (PageListOrderedItemTextTypeID )
return p .EncodeBare (b )
}
func (p *PageListOrderedItemText ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListOrderedItemText#5e068047 as nil" )
}
b .PutString (p .Num )
if p .Text == nil {
return fmt .Errorf ("unable to encode pageListOrderedItemText#5e068047: field text is nil" )
}
if err := p .Text .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageListOrderedItemText#5e068047: field text: %w" , err )
}
return nil
}
func (p *PageListOrderedItemText ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListOrderedItemText#5e068047 to nil" )
}
if err := b .ConsumeID (PageListOrderedItemTextTypeID ); err != nil {
return fmt .Errorf ("unable to decode pageListOrderedItemText#5e068047: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PageListOrderedItemText ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListOrderedItemText#5e068047 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode pageListOrderedItemText#5e068047: field num: %w" , err )
}
p .Num = value
}
{
value , err := DecodeRichText (b )
if err != nil {
return fmt .Errorf ("unable to decode pageListOrderedItemText#5e068047: field text: %w" , err )
}
p .Text = value
}
return nil
}
func (p *PageListOrderedItemText ) GetNum () (value string ) {
if p == nil {
return
}
return p .Num
}
func (p *PageListOrderedItemText ) GetText () (value RichTextClass ) {
if p == nil {
return
}
return p .Text
}
type PageListOrderedItemBlocks struct {
Num string
Blocks []PageBlockClass
}
const PageListOrderedItemBlocksTypeID = 0x98dd8936
func (p PageListOrderedItemBlocks ) construct () PageListOrderedItemClass { return &p }
var (
_ bin .Encoder = &PageListOrderedItemBlocks {}
_ bin .Decoder = &PageListOrderedItemBlocks {}
_ bin .BareEncoder = &PageListOrderedItemBlocks {}
_ bin .BareDecoder = &PageListOrderedItemBlocks {}
_ PageListOrderedItemClass = &PageListOrderedItemBlocks {}
)
func (p *PageListOrderedItemBlocks ) Zero () bool {
if p == nil {
return true
}
if !(p .Num == "" ) {
return false
}
if !(p .Blocks == nil ) {
return false
}
return true
}
func (p *PageListOrderedItemBlocks ) String () string {
if p == nil {
return "PageListOrderedItemBlocks(nil)"
}
type Alias PageListOrderedItemBlocks
return fmt .Sprintf ("PageListOrderedItemBlocks%+v" , Alias (*p ))
}
func (p *PageListOrderedItemBlocks ) FillFrom (from interface {
GetNum () (value string )
GetBlocks () (value []PageBlockClass )
}) {
p .Num = from .GetNum ()
p .Blocks = from .GetBlocks ()
}
func (*PageListOrderedItemBlocks ) TypeID () uint32 {
return PageListOrderedItemBlocksTypeID
}
func (*PageListOrderedItemBlocks ) TypeName () string {
return "pageListOrderedItemBlocks"
}
func (p *PageListOrderedItemBlocks ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "pageListOrderedItemBlocks" ,
ID : PageListOrderedItemBlocksTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Num" ,
SchemaName : "num" ,
},
{
Name : "Blocks" ,
SchemaName : "blocks" ,
},
}
return typ
}
func (p *PageListOrderedItemBlocks ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListOrderedItemBlocks#98dd8936 as nil" )
}
b .PutID (PageListOrderedItemBlocksTypeID )
return p .EncodeBare (b )
}
func (p *PageListOrderedItemBlocks ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageListOrderedItemBlocks#98dd8936 as nil" )
}
b .PutString (p .Num )
b .PutVectorHeader (len (p .Blocks ))
for idx , v := range p .Blocks {
if v == nil {
return fmt .Errorf ("unable to encode pageListOrderedItemBlocks#98dd8936: field blocks element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageListOrderedItemBlocks#98dd8936: field blocks element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *PageListOrderedItemBlocks ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListOrderedItemBlocks#98dd8936 to nil" )
}
if err := b .ConsumeID (PageListOrderedItemBlocksTypeID ); err != nil {
return fmt .Errorf ("unable to decode pageListOrderedItemBlocks#98dd8936: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PageListOrderedItemBlocks ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageListOrderedItemBlocks#98dd8936 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode pageListOrderedItemBlocks#98dd8936: field num: %w" , err )
}
p .Num = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode pageListOrderedItemBlocks#98dd8936: 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 pageListOrderedItemBlocks#98dd8936: field blocks: %w" , err )
}
p .Blocks = append (p .Blocks , value )
}
}
return nil
}
func (p *PageListOrderedItemBlocks ) GetNum () (value string ) {
if p == nil {
return
}
return p .Num
}
func (p *PageListOrderedItemBlocks ) GetBlocks () (value []PageBlockClass ) {
if p == nil {
return
}
return p .Blocks
}
func (p *PageListOrderedItemBlocks ) MapBlocks () (value PageBlockClassArray ) {
return PageBlockClassArray (p .Blocks )
}
const PageListOrderedItemClassName = "PageListOrderedItem"
type PageListOrderedItemClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PageListOrderedItemClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetNum () (value string )
}
func DecodePageListOrderedItem (buf *bin .Buffer ) (PageListOrderedItemClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PageListOrderedItemTextTypeID :
v := PageListOrderedItemText {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PageListOrderedItemClass: %w" , err )
}
return &v , nil
case PageListOrderedItemBlocksTypeID :
v := PageListOrderedItemBlocks {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PageListOrderedItemClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PageListOrderedItemClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PageListOrderedItemBox struct {
PageListOrderedItem PageListOrderedItemClass
}
func (b *PageListOrderedItemBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PageListOrderedItemBox to nil" )
}
v , err := DecodePageListOrderedItem (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .PageListOrderedItem = v
return nil
}
func (b *PageListOrderedItemBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .PageListOrderedItem == nil {
return fmt .Errorf ("unable to encode PageListOrderedItemClass as nil" )
}
return b .PageListOrderedItem .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 .