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 PageCaption struct {
Text RichTextClass
Credit RichTextClass
}
const PageCaptionTypeID = 0x6f747657
var (
_ bin .Encoder = &PageCaption {}
_ bin .Decoder = &PageCaption {}
_ bin .BareEncoder = &PageCaption {}
_ bin .BareDecoder = &PageCaption {}
)
func (p *PageCaption ) Zero () bool {
if p == nil {
return true
}
if !(p .Text == nil ) {
return false
}
if !(p .Credit == nil ) {
return false
}
return true
}
func (p *PageCaption ) String () string {
if p == nil {
return "PageCaption(nil)"
}
type Alias PageCaption
return fmt .Sprintf ("PageCaption%+v" , Alias (*p ))
}
func (p *PageCaption ) FillFrom (from interface {
GetText () (value RichTextClass )
GetCredit () (value RichTextClass )
}) {
p .Text = from .GetText ()
p .Credit = from .GetCredit ()
}
func (*PageCaption ) TypeID () uint32 {
return PageCaptionTypeID
}
func (*PageCaption ) TypeName () string {
return "pageCaption"
}
func (p *PageCaption ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "pageCaption" ,
ID : PageCaptionTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Text" ,
SchemaName : "text" ,
},
{
Name : "Credit" ,
SchemaName : "credit" ,
},
}
return typ
}
func (p *PageCaption ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageCaption#6f747657 as nil" )
}
b .PutID (PageCaptionTypeID )
return p .EncodeBare (b )
}
func (p *PageCaption ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageCaption#6f747657 as nil" )
}
if p .Text == nil {
return fmt .Errorf ("unable to encode pageCaption#6f747657: field text is nil" )
}
if err := p .Text .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageCaption#6f747657: field text: %w" , err )
}
if p .Credit == nil {
return fmt .Errorf ("unable to encode pageCaption#6f747657: field credit is nil" )
}
if err := p .Credit .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageCaption#6f747657: field credit: %w" , err )
}
return nil
}
func (p *PageCaption ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageCaption#6f747657 to nil" )
}
if err := b .ConsumeID (PageCaptionTypeID ); err != nil {
return fmt .Errorf ("unable to decode pageCaption#6f747657: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PageCaption ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageCaption#6f747657 to nil" )
}
{
value , err := DecodeRichText (b )
if err != nil {
return fmt .Errorf ("unable to decode pageCaption#6f747657: field text: %w" , err )
}
p .Text = value
}
{
value , err := DecodeRichText (b )
if err != nil {
return fmt .Errorf ("unable to decode pageCaption#6f747657: field credit: %w" , err )
}
p .Credit = value
}
return nil
}
func (p *PageCaption ) GetText () (value RichTextClass ) {
if p == nil {
return
}
return p .Text
}
func (p *PageCaption ) GetCredit () (value RichTextClass ) {
if p == nil {
return
}
return p .Credit
}
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 .