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 HighScore struct {
Pos int
UserID int64
Score int
}
const HighScoreTypeID = 0x73a379eb
var (
_ bin .Encoder = &HighScore {}
_ bin .Decoder = &HighScore {}
_ bin .BareEncoder = &HighScore {}
_ bin .BareDecoder = &HighScore {}
)
func (h *HighScore ) Zero () bool {
if h == nil {
return true
}
if !(h .Pos == 0 ) {
return false
}
if !(h .UserID == 0 ) {
return false
}
if !(h .Score == 0 ) {
return false
}
return true
}
func (h *HighScore ) String () string {
if h == nil {
return "HighScore(nil)"
}
type Alias HighScore
return fmt .Sprintf ("HighScore%+v" , Alias (*h ))
}
func (h *HighScore ) FillFrom (from interface {
GetPos () (value int )
GetUserID () (value int64 )
GetScore () (value int )
}) {
h .Pos = from .GetPos ()
h .UserID = from .GetUserID ()
h .Score = from .GetScore ()
}
func (*HighScore ) TypeID () uint32 {
return HighScoreTypeID
}
func (*HighScore ) TypeName () string {
return "highScore"
}
func (h *HighScore ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "highScore" ,
ID : HighScoreTypeID ,
}
if h == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Pos" ,
SchemaName : "pos" ,
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Score" ,
SchemaName : "score" ,
},
}
return typ
}
func (h *HighScore ) Encode (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't encode highScore#73a379eb as nil" )
}
b .PutID (HighScoreTypeID )
return h .EncodeBare (b )
}
func (h *HighScore ) EncodeBare (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't encode highScore#73a379eb as nil" )
}
b .PutInt (h .Pos )
b .PutLong (h .UserID )
b .PutInt (h .Score )
return nil
}
func (h *HighScore ) Decode (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't decode highScore#73a379eb to nil" )
}
if err := b .ConsumeID (HighScoreTypeID ); err != nil {
return fmt .Errorf ("unable to decode highScore#73a379eb: %w" , err )
}
return h .DecodeBare (b )
}
func (h *HighScore ) DecodeBare (b *bin .Buffer ) error {
if h == nil {
return fmt .Errorf ("can't decode highScore#73a379eb to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode highScore#73a379eb: field pos: %w" , err )
}
h .Pos = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode highScore#73a379eb: field user_id: %w" , err )
}
h .UserID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode highScore#73a379eb: field score: %w" , err )
}
h .Score = value
}
return nil
}
func (h *HighScore ) GetPos () (value int ) {
if h == nil {
return
}
return h .Pos
}
func (h *HighScore ) GetUserID () (value int64 ) {
if h == nil {
return
}
return h .UserID
}
func (h *HighScore ) GetScore () (value int ) {
if h == nil {
return
}
return h .Score
}
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 .