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 PollAnswerVoters struct {
Flags bin .Fields
Chosen bool
Correct bool
Option []byte
Voters int
}
const PollAnswerVotersTypeID = 0x3b6ddad2
var (
_ bin .Encoder = &PollAnswerVoters {}
_ bin .Decoder = &PollAnswerVoters {}
_ bin .BareEncoder = &PollAnswerVoters {}
_ bin .BareDecoder = &PollAnswerVoters {}
)
func (p *PollAnswerVoters ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Chosen == false ) {
return false
}
if !(p .Correct == false ) {
return false
}
if !(p .Option == nil ) {
return false
}
if !(p .Voters == 0 ) {
return false
}
return true
}
func (p *PollAnswerVoters ) String () string {
if p == nil {
return "PollAnswerVoters(nil)"
}
type Alias PollAnswerVoters
return fmt .Sprintf ("PollAnswerVoters%+v" , Alias (*p ))
}
func (p *PollAnswerVoters ) FillFrom (from interface {
GetChosen () (value bool )
GetCorrect () (value bool )
GetOption () (value []byte )
GetVoters () (value int )
}) {
p .Chosen = from .GetChosen ()
p .Correct = from .GetCorrect ()
p .Option = from .GetOption ()
p .Voters = from .GetVoters ()
}
func (*PollAnswerVoters ) TypeID () uint32 {
return PollAnswerVotersTypeID
}
func (*PollAnswerVoters ) TypeName () string {
return "pollAnswerVoters"
}
func (p *PollAnswerVoters ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "pollAnswerVoters" ,
ID : PollAnswerVotersTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Chosen" ,
SchemaName : "chosen" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "Correct" ,
SchemaName : "correct" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "Option" ,
SchemaName : "option" ,
},
{
Name : "Voters" ,
SchemaName : "voters" ,
},
}
return typ
}
func (p *PollAnswerVoters ) SetFlags () {
if !(p .Chosen == false ) {
p .Flags .Set (0 )
}
if !(p .Correct == false ) {
p .Flags .Set (1 )
}
}
func (p *PollAnswerVoters ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pollAnswerVoters#3b6ddad2 as nil" )
}
b .PutID (PollAnswerVotersTypeID )
return p .EncodeBare (b )
}
func (p *PollAnswerVoters ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pollAnswerVoters#3b6ddad2 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pollAnswerVoters#3b6ddad2: field flags: %w" , err )
}
b .PutBytes (p .Option )
b .PutInt (p .Voters )
return nil
}
func (p *PollAnswerVoters ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pollAnswerVoters#3b6ddad2 to nil" )
}
if err := b .ConsumeID (PollAnswerVotersTypeID ); err != nil {
return fmt .Errorf ("unable to decode pollAnswerVoters#3b6ddad2: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PollAnswerVoters ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pollAnswerVoters#3b6ddad2 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode pollAnswerVoters#3b6ddad2: field flags: %w" , err )
}
}
p .Chosen = p .Flags .Has (0 )
p .Correct = p .Flags .Has (1 )
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode pollAnswerVoters#3b6ddad2: field option: %w" , err )
}
p .Option = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode pollAnswerVoters#3b6ddad2: field voters: %w" , err )
}
p .Voters = value
}
return nil
}
func (p *PollAnswerVoters ) SetChosen (value bool ) {
if value {
p .Flags .Set (0 )
p .Chosen = true
} else {
p .Flags .Unset (0 )
p .Chosen = false
}
}
func (p *PollAnswerVoters ) GetChosen () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (0 )
}
func (p *PollAnswerVoters ) SetCorrect (value bool ) {
if value {
p .Flags .Set (1 )
p .Correct = true
} else {
p .Flags .Unset (1 )
p .Correct = false
}
}
func (p *PollAnswerVoters ) GetCorrect () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (1 )
}
func (p *PollAnswerVoters ) GetOption () (value []byte ) {
if p == nil {
return
}
return p .Option
}
func (p *PollAnswerVoters ) GetVoters () (value int ) {
if p == nil {
return
}
return p .Voters
}
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 .