Files
mautrix-telegram/pkg/gotd/tg/tl_star_gift_attribute_counter_gen.go
T
2025-12-03 17:11:20 +02:00

195 lines
4.8 KiB
Go
Generated

// Code generated by gotdgen, DO NOT EDIT.
package tg
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{}
)
// StarGiftAttributeCounter represents TL type `starGiftAttributeCounter#2eb1b658`.
// Indicates the total number of gifts that have the specified attribute.
//
// See https://core.telegram.org/constructor/starGiftAttributeCounter for reference.
type StarGiftAttributeCounter struct {
// The attribute (just the ID, without the attribute itself).
Attribute StarGiftAttributeIDClass
// Total number of gifts with this attribute.
Count int
}
// StarGiftAttributeCounterTypeID is TL type id of StarGiftAttributeCounter.
const StarGiftAttributeCounterTypeID = 0x2eb1b658
// Ensuring interfaces in compile-time for StarGiftAttributeCounter.
var (
_ bin.Encoder = &StarGiftAttributeCounter{}
_ bin.Decoder = &StarGiftAttributeCounter{}
_ bin.BareEncoder = &StarGiftAttributeCounter{}
_ bin.BareDecoder = &StarGiftAttributeCounter{}
)
func (s *StarGiftAttributeCounter) Zero() bool {
if s == nil {
return true
}
if !(s.Attribute == nil) {
return false
}
if !(s.Count == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *StarGiftAttributeCounter) String() string {
if s == nil {
return "StarGiftAttributeCounter(nil)"
}
type Alias StarGiftAttributeCounter
return fmt.Sprintf("StarGiftAttributeCounter%+v", Alias(*s))
}
// FillFrom fills StarGiftAttributeCounter from given interface.
func (s *StarGiftAttributeCounter) FillFrom(from interface {
GetAttribute() (value StarGiftAttributeIDClass)
GetCount() (value int)
}) {
s.Attribute = from.GetAttribute()
s.Count = from.GetCount()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StarGiftAttributeCounter) TypeID() uint32 {
return StarGiftAttributeCounterTypeID
}
// TypeName returns name of type in TL schema.
func (*StarGiftAttributeCounter) TypeName() string {
return "starGiftAttributeCounter"
}
// TypeInfo returns info about TL type.
func (s *StarGiftAttributeCounter) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "starGiftAttributeCounter",
ID: StarGiftAttributeCounterTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Attribute",
SchemaName: "attribute",
},
{
Name: "Count",
SchemaName: "count",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *StarGiftAttributeCounter) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode starGiftAttributeCounter#2eb1b658 as nil")
}
b.PutID(StarGiftAttributeCounterTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StarGiftAttributeCounter) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode starGiftAttributeCounter#2eb1b658 as nil")
}
if s.Attribute == nil {
return fmt.Errorf("unable to encode starGiftAttributeCounter#2eb1b658: field attribute is nil")
}
if err := s.Attribute.Encode(b); err != nil {
return fmt.Errorf("unable to encode starGiftAttributeCounter#2eb1b658: field attribute: %w", err)
}
b.PutInt(s.Count)
return nil
}
// Decode implements bin.Decoder.
func (s *StarGiftAttributeCounter) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode starGiftAttributeCounter#2eb1b658 to nil")
}
if err := b.ConsumeID(StarGiftAttributeCounterTypeID); err != nil {
return fmt.Errorf("unable to decode starGiftAttributeCounter#2eb1b658: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StarGiftAttributeCounter) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode starGiftAttributeCounter#2eb1b658 to nil")
}
{
value, err := DecodeStarGiftAttributeID(b)
if err != nil {
return fmt.Errorf("unable to decode starGiftAttributeCounter#2eb1b658: field attribute: %w", err)
}
s.Attribute = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode starGiftAttributeCounter#2eb1b658: field count: %w", err)
}
s.Count = value
}
return nil
}
// GetAttribute returns value of Attribute field.
func (s *StarGiftAttributeCounter) GetAttribute() (value StarGiftAttributeIDClass) {
if s == nil {
return
}
return s.Attribute
}
// GetCount returns value of Count field.
func (s *StarGiftAttributeCounter) GetCount() (value int) {
if s == nil {
return
}
return s.Count
}