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 PremiumBoostsList struct {
Flags bin .Fields
Count int
Boosts []Boost
NextOffset string
Users []UserClass
}
const PremiumBoostsListTypeID = 0x86f8613c
var (
_ bin .Encoder = &PremiumBoostsList {}
_ bin .Decoder = &PremiumBoostsList {}
_ bin .BareEncoder = &PremiumBoostsList {}
_ bin .BareDecoder = &PremiumBoostsList {}
)
func (b *PremiumBoostsList ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .Count == 0 ) {
return false
}
if !(b .Boosts == nil ) {
return false
}
if !(b .NextOffset == "" ) {
return false
}
if !(b .Users == nil ) {
return false
}
return true
}
func (b *PremiumBoostsList ) String () string {
if b == nil {
return "PremiumBoostsList(nil)"
}
type Alias PremiumBoostsList
return fmt .Sprintf ("PremiumBoostsList%+v" , Alias (*b ))
}
func (b *PremiumBoostsList ) FillFrom (from interface {
GetCount () (value int )
GetBoosts () (value []Boost )
GetNextOffset () (value string , ok bool )
GetUsers () (value []UserClass )
}) {
b .Count = from .GetCount ()
b .Boosts = from .GetBoosts ()
if val , ok := from .GetNextOffset (); ok {
b .NextOffset = val
}
b .Users = from .GetUsers ()
}
func (*PremiumBoostsList ) TypeID () uint32 {
return PremiumBoostsListTypeID
}
func (*PremiumBoostsList ) TypeName () string {
return "premium.boostsList"
}
func (b *PremiumBoostsList ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "premium.boostsList" ,
ID : PremiumBoostsListTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Boosts" ,
SchemaName : "boosts" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (b *PremiumBoostsList ) SetFlags () {
if !(b .NextOffset == "" ) {
b .Flags .Set (0 )
}
}
func (b *PremiumBoostsList ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode premium.boostsList#86f8613c as nil" )
}
buf .PutID (PremiumBoostsListTypeID )
return b .EncodeBare (buf )
}
func (b *PremiumBoostsList ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode premium.boostsList#86f8613c as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode premium.boostsList#86f8613c: field flags: %w" , err )
}
buf .PutInt (b .Count )
buf .PutVectorHeader (len (b .Boosts ))
for idx , v := range b .Boosts {
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode premium.boostsList#86f8613c: field boosts element with index %d: %w" , idx , err )
}
}
if b .Flags .Has (0 ) {
buf .PutString (b .NextOffset )
}
buf .PutVectorHeader (len (b .Users ))
for idx , v := range b .Users {
if v == nil {
return fmt .Errorf ("unable to encode premium.boostsList#86f8613c: field users element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode premium.boostsList#86f8613c: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (b *PremiumBoostsList ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode premium.boostsList#86f8613c to nil" )
}
if err := buf .ConsumeID (PremiumBoostsListTypeID ); err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *PremiumBoostsList ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode premium.boostsList#86f8613c to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: field flags: %w" , err )
}
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: field count: %w" , err )
}
b .Count = value
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: field boosts: %w" , err )
}
if headerLen > 0 {
b .Boosts = make ([]Boost , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value Boost
if err := value .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: field boosts: %w" , err )
}
b .Boosts = append (b .Boosts , value )
}
}
if b .Flags .Has (0 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: field next_offset: %w" , err )
}
b .NextOffset = value
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: field users: %w" , err )
}
if headerLen > 0 {
b .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (buf )
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsList#86f8613c: field users: %w" , err )
}
b .Users = append (b .Users , value )
}
}
return nil
}
func (b *PremiumBoostsList ) GetCount () (value int ) {
if b == nil {
return
}
return b .Count
}
func (b *PremiumBoostsList ) GetBoosts () (value []Boost ) {
if b == nil {
return
}
return b .Boosts
}
func (b *PremiumBoostsList ) SetNextOffset (value string ) {
b .Flags .Set (0 )
b .NextOffset = value
}
func (b *PremiumBoostsList ) GetNextOffset () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (0 ) {
return value , false
}
return b .NextOffset , true
}
func (b *PremiumBoostsList ) GetUsers () (value []UserClass ) {
if b == nil {
return
}
return b .Users
}
func (b *PremiumBoostsList ) MapUsers () (value UserClassArray ) {
return UserClassArray (b .Users )
}
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 .