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

263 lines
6.7 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{}
)
// GetLanguagePackStringsRequest represents TL type `getLanguagePackStrings#b0b867bb`.
type GetLanguagePackStringsRequest struct {
// Language pack identifier of the strings to be returned
LanguagePackID string
// Language pack keys of the strings to be returned; leave empty to request all available
// strings
Keys []string
}
// GetLanguagePackStringsRequestTypeID is TL type id of GetLanguagePackStringsRequest.
const GetLanguagePackStringsRequestTypeID = 0xb0b867bb
// Ensuring interfaces in compile-time for GetLanguagePackStringsRequest.
var (
_ bin.Encoder = &GetLanguagePackStringsRequest{}
_ bin.Decoder = &GetLanguagePackStringsRequest{}
_ bin.BareEncoder = &GetLanguagePackStringsRequest{}
_ bin.BareDecoder = &GetLanguagePackStringsRequest{}
)
func (g *GetLanguagePackStringsRequest) Zero() bool {
if g == nil {
return true
}
if !(g.LanguagePackID == "") {
return false
}
if !(g.Keys == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *GetLanguagePackStringsRequest) String() string {
if g == nil {
return "GetLanguagePackStringsRequest(nil)"
}
type Alias GetLanguagePackStringsRequest
return fmt.Sprintf("GetLanguagePackStringsRequest%+v", Alias(*g))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*GetLanguagePackStringsRequest) TypeID() uint32 {
return GetLanguagePackStringsRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*GetLanguagePackStringsRequest) TypeName() string {
return "getLanguagePackStrings"
}
// TypeInfo returns info about TL type.
func (g *GetLanguagePackStringsRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "getLanguagePackStrings",
ID: GetLanguagePackStringsRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "LanguagePackID",
SchemaName: "language_pack_id",
},
{
Name: "Keys",
SchemaName: "keys",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *GetLanguagePackStringsRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getLanguagePackStrings#b0b867bb as nil")
}
b.PutID(GetLanguagePackStringsRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *GetLanguagePackStringsRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getLanguagePackStrings#b0b867bb as nil")
}
b.PutString(g.LanguagePackID)
b.PutInt(len(g.Keys))
for _, v := range g.Keys {
b.PutString(v)
}
return nil
}
// Decode implements bin.Decoder.
func (g *GetLanguagePackStringsRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getLanguagePackStrings#b0b867bb to nil")
}
if err := b.ConsumeID(GetLanguagePackStringsRequestTypeID); err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *GetLanguagePackStringsRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getLanguagePackStrings#b0b867bb to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: field language_pack_id: %w", err)
}
g.LanguagePackID = value
}
{
headerLen, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: field keys: %w", err)
}
if headerLen > 0 {
g.Keys = make([]string, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: field keys: %w", err)
}
g.Keys = append(g.Keys, value)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetLanguagePackStringsRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if g == nil {
return fmt.Errorf("can't encode getLanguagePackStrings#b0b867bb as nil")
}
b.ObjStart()
b.PutID("getLanguagePackStrings")
b.Comma()
b.FieldStart("language_pack_id")
b.PutString(g.LanguagePackID)
b.Comma()
b.FieldStart("keys")
b.ArrStart()
for _, v := range g.Keys {
b.PutString(v)
b.Comma()
}
b.StripComma()
b.ArrEnd()
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetLanguagePackStringsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if g == nil {
return fmt.Errorf("can't decode getLanguagePackStrings#b0b867bb to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("getLanguagePackStrings"); err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: %w", err)
}
case "language_pack_id":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: field language_pack_id: %w", err)
}
g.LanguagePackID = value
case "keys":
if err := b.Arr(func(b tdjson.Decoder) error {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: field keys: %w", err)
}
g.Keys = append(g.Keys, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode getLanguagePackStrings#b0b867bb: field keys: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetLanguagePackID returns value of LanguagePackID field.
func (g *GetLanguagePackStringsRequest) GetLanguagePackID() (value string) {
if g == nil {
return
}
return g.LanguagePackID
}
// GetKeys returns value of Keys field.
func (g *GetLanguagePackStringsRequest) GetKeys() (value []string) {
if g == nil {
return
}
return g.Keys
}
// GetLanguagePackStrings invokes method getLanguagePackStrings#b0b867bb returning error if any.
func (c *Client) GetLanguagePackStrings(ctx context.Context, request *GetLanguagePackStringsRequest) (*LanguagePackStrings, error) {
var result LanguagePackStrings
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}