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

228 lines
5.0 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{}
)
// StarAmount represents TL type `starAmount#6f0e6d80`.
type StarAmount struct {
// The integer amount of Telegram Stars rounded to 0
StarCount int64
// The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999
NanostarCount int32
}
// StarAmountTypeID is TL type id of StarAmount.
const StarAmountTypeID = 0x6f0e6d80
// Ensuring interfaces in compile-time for StarAmount.
var (
_ bin.Encoder = &StarAmount{}
_ bin.Decoder = &StarAmount{}
_ bin.BareEncoder = &StarAmount{}
_ bin.BareDecoder = &StarAmount{}
)
func (s *StarAmount) Zero() bool {
if s == nil {
return true
}
if !(s.StarCount == 0) {
return false
}
if !(s.NanostarCount == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *StarAmount) String() string {
if s == nil {
return "StarAmount(nil)"
}
type Alias StarAmount
return fmt.Sprintf("StarAmount%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StarAmount) TypeID() uint32 {
return StarAmountTypeID
}
// TypeName returns name of type in TL schema.
func (*StarAmount) TypeName() string {
return "starAmount"
}
// TypeInfo returns info about TL type.
func (s *StarAmount) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "starAmount",
ID: StarAmountTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "StarCount",
SchemaName: "star_count",
},
{
Name: "NanostarCount",
SchemaName: "nanostar_count",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *StarAmount) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode starAmount#6f0e6d80 as nil")
}
b.PutID(StarAmountTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StarAmount) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode starAmount#6f0e6d80 as nil")
}
b.PutInt53(s.StarCount)
b.PutInt32(s.NanostarCount)
return nil
}
// Decode implements bin.Decoder.
func (s *StarAmount) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode starAmount#6f0e6d80 to nil")
}
if err := b.ConsumeID(StarAmountTypeID); err != nil {
return fmt.Errorf("unable to decode starAmount#6f0e6d80: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StarAmount) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode starAmount#6f0e6d80 to nil")
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode starAmount#6f0e6d80: field star_count: %w", err)
}
s.StarCount = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode starAmount#6f0e6d80: field nanostar_count: %w", err)
}
s.NanostarCount = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarAmount) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode starAmount#6f0e6d80 as nil")
}
b.ObjStart()
b.PutID("starAmount")
b.Comma()
b.FieldStart("star_count")
b.PutInt53(s.StarCount)
b.Comma()
b.FieldStart("nanostar_count")
b.PutInt32(s.NanostarCount)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarAmount) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode starAmount#6f0e6d80 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("starAmount"); err != nil {
return fmt.Errorf("unable to decode starAmount#6f0e6d80: %w", err)
}
case "star_count":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode starAmount#6f0e6d80: field star_count: %w", err)
}
s.StarCount = value
case "nanostar_count":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode starAmount#6f0e6d80: field nanostar_count: %w", err)
}
s.NanostarCount = value
default:
return b.Skip()
}
return nil
})
}
// GetStarCount returns value of StarCount field.
func (s *StarAmount) GetStarCount() (value int64) {
if s == nil {
return
}
return s.StarCount
}
// GetNanostarCount returns value of NanostarCount field.
func (s *StarAmount) GetNanostarCount() (value int32) {
if s == nil {
return
}
return s.NanostarCount
}