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 MessagesHighScores struct {
Scores []HighScore
Users []UserClass
}
const MessagesHighScoresTypeID = 0x9a3bfd99
var (
_ bin .Encoder = &MessagesHighScores {}
_ bin .Decoder = &MessagesHighScores {}
_ bin .BareEncoder = &MessagesHighScores {}
_ bin .BareDecoder = &MessagesHighScores {}
)
func (h *MessagesHighScores ) Zero () bool {
if h == nil {
return true
}
if !(h .Scores == nil ) {
return false
}
if !(h .Users == nil ) {
return false
}
return true
}
func (h *MessagesHighScores ) String () string {
if h == nil {
return "MessagesHighScores(nil)"
}
type Alias MessagesHighScores
return fmt .Sprintf ("MessagesHighScores%+v" , Alias (*h ))
}
func (h *MessagesHighScores ) FillFrom (from interface {
GetScores () (value []HighScore )
GetUsers () (value []UserClass )
}) {
h .Scores = from .GetScores ()
h .Users = from .GetUsers ()
}
func (*MessagesHighScores ) TypeID () uint32 {
return MessagesHighScoresTypeID
}
func (*MessagesHighScores ) TypeName () string {
return "messages.highScores"
}
func (h *MessagesHighScores ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.highScores" ,
ID : MessagesHighScoresTypeID ,
}
if h == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Scores" ,
SchemaName : "scores" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (h *MessagesHighScores ) Encode (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't encode messages.highScores#9a3bfd99 as nil" )
}
b .PutID (MessagesHighScoresTypeID )
return h .EncodeBare (b )
}
func (h *MessagesHighScores ) EncodeBare (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't encode messages.highScores#9a3bfd99 as nil" )
}
b .PutVectorHeader (len (h .Scores ))
for idx , v := range h .Scores {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.highScores#9a3bfd99: field scores element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (h .Users ))
for idx , v := range h .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.highScores#9a3bfd99: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.highScores#9a3bfd99: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (h *MessagesHighScores ) Decode (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't decode messages.highScores#9a3bfd99 to nil" )
}
if err := b .ConsumeID (MessagesHighScoresTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.highScores#9a3bfd99: %w" , err )
}
return h .DecodeBare (b )
}
func (h *MessagesHighScores ) DecodeBare (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't decode messages.highScores#9a3bfd99 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.highScores#9a3bfd99: field scores: %w" , err )
}
if headerLen > 0 {
h .Scores = make ([]HighScore , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value HighScore
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.highScores#9a3bfd99: field scores: %w" , err )
}
h .Scores = append (h .Scores , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.highScores#9a3bfd99: field users: %w" , err )
}
if headerLen > 0 {
h .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.highScores#9a3bfd99: field users: %w" , err )
}
h .Users = append (h .Users , value )
}
}
return nil
}
func (h *MessagesHighScores ) GetScores () (value []HighScore ) {
if h == nil {
return
}
return h .Scores
}
func (h *MessagesHighScores ) GetUsers () (value []UserClass ) {
if h == nil {
return
}
return h .Users
}
func (h *MessagesHighScores ) MapUsers () (value UserClassArray ) {
return UserClassArray (h .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 .