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

222 lines
5.5 KiB
Go
Generated

// 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{}
)
// LanguagePackStrings represents TL type `languagePackStrings#4aa681ef`.
type LanguagePackStrings struct {
// A list of language pack strings
Strings []LanguagePackString
}
// LanguagePackStringsTypeID is TL type id of LanguagePackStrings.
const LanguagePackStringsTypeID = 0x4aa681ef
// Ensuring interfaces in compile-time for LanguagePackStrings.
var (
_ bin.Encoder = &LanguagePackStrings{}
_ bin.Decoder = &LanguagePackStrings{}
_ bin.BareEncoder = &LanguagePackStrings{}
_ bin.BareDecoder = &LanguagePackStrings{}
)
func (l *LanguagePackStrings) Zero() bool {
if l == nil {
return true
}
if !(l.Strings == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (l *LanguagePackStrings) String() string {
if l == nil {
return "LanguagePackStrings(nil)"
}
type Alias LanguagePackStrings
return fmt.Sprintf("LanguagePackStrings%+v", Alias(*l))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*LanguagePackStrings) TypeID() uint32 {
return LanguagePackStringsTypeID
}
// TypeName returns name of type in TL schema.
func (*LanguagePackStrings) TypeName() string {
return "languagePackStrings"
}
// TypeInfo returns info about TL type.
func (l *LanguagePackStrings) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "languagePackStrings",
ID: LanguagePackStringsTypeID,
}
if l == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Strings",
SchemaName: "strings",
},
}
return typ
}
// Encode implements bin.Encoder.
func (l *LanguagePackStrings) Encode(b *bin.Buffer) error {
if l == nil {
return fmt.Errorf("can't encode languagePackStrings#4aa681ef as nil")
}
b.PutID(LanguagePackStringsTypeID)
return l.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (l *LanguagePackStrings) EncodeBare(b *bin.Buffer) error {
if l == nil {
return fmt.Errorf("can't encode languagePackStrings#4aa681ef as nil")
}
b.PutInt(len(l.Strings))
for idx, v := range l.Strings {
if err := v.EncodeBare(b); err != nil {
return fmt.Errorf("unable to encode bare languagePackStrings#4aa681ef: field strings element with index %d: %w", idx, err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (l *LanguagePackStrings) Decode(b *bin.Buffer) error {
if l == nil {
return fmt.Errorf("can't decode languagePackStrings#4aa681ef to nil")
}
if err := b.ConsumeID(LanguagePackStringsTypeID); err != nil {
return fmt.Errorf("unable to decode languagePackStrings#4aa681ef: %w", err)
}
return l.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (l *LanguagePackStrings) DecodeBare(b *bin.Buffer) error {
if l == nil {
return fmt.Errorf("can't decode languagePackStrings#4aa681ef to nil")
}
{
headerLen, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode languagePackStrings#4aa681ef: field strings: %w", err)
}
if headerLen > 0 {
l.Strings = make([]LanguagePackString, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
var value LanguagePackString
if err := value.DecodeBare(b); err != nil {
return fmt.Errorf("unable to decode bare languagePackStrings#4aa681ef: field strings: %w", err)
}
l.Strings = append(l.Strings, value)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (l *LanguagePackStrings) EncodeTDLibJSON(b tdjson.Encoder) error {
if l == nil {
return fmt.Errorf("can't encode languagePackStrings#4aa681ef as nil")
}
b.ObjStart()
b.PutID("languagePackStrings")
b.Comma()
b.FieldStart("strings")
b.ArrStart()
for idx, v := range l.Strings {
if err := v.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode languagePackStrings#4aa681ef: field strings element with index %d: %w", idx, err)
}
b.Comma()
}
b.StripComma()
b.ArrEnd()
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (l *LanguagePackStrings) DecodeTDLibJSON(b tdjson.Decoder) error {
if l == nil {
return fmt.Errorf("can't decode languagePackStrings#4aa681ef to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("languagePackStrings"); err != nil {
return fmt.Errorf("unable to decode languagePackStrings#4aa681ef: %w", err)
}
case "strings":
if err := b.Arr(func(b tdjson.Decoder) error {
var value LanguagePackString
if err := value.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode languagePackStrings#4aa681ef: field strings: %w", err)
}
l.Strings = append(l.Strings, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode languagePackStrings#4aa681ef: field strings: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetStrings returns value of Strings field.
func (l *LanguagePackStrings) GetStrings() (value []LanguagePackString) {
if l == nil {
return
}
return l.Strings
}