Files
mautrix-telegram/pkg/gotd/tdapi/tl_upgraded_gift_symbol_count_gen.go
T
2025-06-27 20:03:37 -07:00

228 lines
5.6 KiB
Go

// Code generated by gotdgen, DO NOT EDIT.
package tdapi
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// UpgradedGiftSymbolCount represents TL type `upgradedGiftSymbolCount#d1e41b9e`.
type UpgradedGiftSymbolCount struct {
// The symbol
Symbol UpgradedGiftSymbol
// Total number of gifts with the symbol
TotalCount int32
}
// UpgradedGiftSymbolCountTypeID is TL type id of UpgradedGiftSymbolCount.
const UpgradedGiftSymbolCountTypeID = 0xd1e41b9e
// Ensuring interfaces in compile-time for UpgradedGiftSymbolCount.
var (
_ bin.Encoder = &UpgradedGiftSymbolCount{}
_ bin.Decoder = &UpgradedGiftSymbolCount{}
_ bin.BareEncoder = &UpgradedGiftSymbolCount{}
_ bin.BareDecoder = &UpgradedGiftSymbolCount{}
)
func (u *UpgradedGiftSymbolCount) Zero() bool {
if u == nil {
return true
}
if !(u.Symbol.Zero()) {
return false
}
if !(u.TotalCount == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (u *UpgradedGiftSymbolCount) String() string {
if u == nil {
return "UpgradedGiftSymbolCount(nil)"
}
type Alias UpgradedGiftSymbolCount
return fmt.Sprintf("UpgradedGiftSymbolCount%+v", Alias(*u))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*UpgradedGiftSymbolCount) TypeID() uint32 {
return UpgradedGiftSymbolCountTypeID
}
// TypeName returns name of type in TL schema.
func (*UpgradedGiftSymbolCount) TypeName() string {
return "upgradedGiftSymbolCount"
}
// TypeInfo returns info about TL type.
func (u *UpgradedGiftSymbolCount) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "upgradedGiftSymbolCount",
ID: UpgradedGiftSymbolCountTypeID,
}
if u == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Symbol",
SchemaName: "symbol",
},
{
Name: "TotalCount",
SchemaName: "total_count",
},
}
return typ
}
// Encode implements bin.Encoder.
func (u *UpgradedGiftSymbolCount) Encode(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't encode upgradedGiftSymbolCount#d1e41b9e as nil")
}
b.PutID(UpgradedGiftSymbolCountTypeID)
return u.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (u *UpgradedGiftSymbolCount) EncodeBare(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't encode upgradedGiftSymbolCount#d1e41b9e as nil")
}
if err := u.Symbol.Encode(b); err != nil {
return fmt.Errorf("unable to encode upgradedGiftSymbolCount#d1e41b9e: field symbol: %w", err)
}
b.PutInt32(u.TotalCount)
return nil
}
// Decode implements bin.Decoder.
func (u *UpgradedGiftSymbolCount) Decode(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't decode upgradedGiftSymbolCount#d1e41b9e to nil")
}
if err := b.ConsumeID(UpgradedGiftSymbolCountTypeID); err != nil {
return fmt.Errorf("unable to decode upgradedGiftSymbolCount#d1e41b9e: %w", err)
}
return u.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (u *UpgradedGiftSymbolCount) DecodeBare(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't decode upgradedGiftSymbolCount#d1e41b9e to nil")
}
{
if err := u.Symbol.Decode(b); err != nil {
return fmt.Errorf("unable to decode upgradedGiftSymbolCount#d1e41b9e: field symbol: %w", err)
}
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode upgradedGiftSymbolCount#d1e41b9e: field total_count: %w", err)
}
u.TotalCount = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (u *UpgradedGiftSymbolCount) EncodeTDLibJSON(b tdjson.Encoder) error {
if u == nil {
return fmt.Errorf("can't encode upgradedGiftSymbolCount#d1e41b9e as nil")
}
b.ObjStart()
b.PutID("upgradedGiftSymbolCount")
b.Comma()
b.FieldStart("symbol")
if err := u.Symbol.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode upgradedGiftSymbolCount#d1e41b9e: field symbol: %w", err)
}
b.Comma()
b.FieldStart("total_count")
b.PutInt32(u.TotalCount)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (u *UpgradedGiftSymbolCount) DecodeTDLibJSON(b tdjson.Decoder) error {
if u == nil {
return fmt.Errorf("can't decode upgradedGiftSymbolCount#d1e41b9e to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("upgradedGiftSymbolCount"); err != nil {
return fmt.Errorf("unable to decode upgradedGiftSymbolCount#d1e41b9e: %w", err)
}
case "symbol":
if err := u.Symbol.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode upgradedGiftSymbolCount#d1e41b9e: field symbol: %w", err)
}
case "total_count":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode upgradedGiftSymbolCount#d1e41b9e: field total_count: %w", err)
}
u.TotalCount = value
default:
return b.Skip()
}
return nil
})
}
// GetSymbol returns value of Symbol field.
func (u *UpgradedGiftSymbolCount) GetSymbol() (value UpgradedGiftSymbol) {
if u == nil {
return
}
return u.Symbol
}
// GetTotalCount returns value of TotalCount field.
func (u *UpgradedGiftSymbolCount) GetTotalCount() (value int32) {
if u == nil {
return
}
return u.TotalCount
}