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