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

413 lines
10 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{}
)
// HelpAppConfigNotModified represents TL type `help.appConfigNotModified#7cde641d`.
// The client configuration parameters haven't changed
//
// See https://core.telegram.org/constructor/help.appConfigNotModified for reference.
type HelpAppConfigNotModified struct {
}
// HelpAppConfigNotModifiedTypeID is TL type id of HelpAppConfigNotModified.
const HelpAppConfigNotModifiedTypeID = 0x7cde641d
// construct implements constructor of HelpAppConfigClass.
func (a HelpAppConfigNotModified) construct() HelpAppConfigClass { return &a }
// Ensuring interfaces in compile-time for HelpAppConfigNotModified.
var (
_ bin.Encoder = &HelpAppConfigNotModified{}
_ bin.Decoder = &HelpAppConfigNotModified{}
_ bin.BareEncoder = &HelpAppConfigNotModified{}
_ bin.BareDecoder = &HelpAppConfigNotModified{}
_ HelpAppConfigClass = &HelpAppConfigNotModified{}
)
func (a *HelpAppConfigNotModified) Zero() bool {
if a == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (a *HelpAppConfigNotModified) String() string {
if a == nil {
return "HelpAppConfigNotModified(nil)"
}
type Alias HelpAppConfigNotModified
return fmt.Sprintf("HelpAppConfigNotModified%+v", Alias(*a))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*HelpAppConfigNotModified) TypeID() uint32 {
return HelpAppConfigNotModifiedTypeID
}
// TypeName returns name of type in TL schema.
func (*HelpAppConfigNotModified) TypeName() string {
return "help.appConfigNotModified"
}
// TypeInfo returns info about TL type.
func (a *HelpAppConfigNotModified) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "help.appConfigNotModified",
ID: HelpAppConfigNotModifiedTypeID,
}
if a == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (a *HelpAppConfigNotModified) Encode(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't encode help.appConfigNotModified#7cde641d as nil")
}
b.PutID(HelpAppConfigNotModifiedTypeID)
return a.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (a *HelpAppConfigNotModified) EncodeBare(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't encode help.appConfigNotModified#7cde641d as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (a *HelpAppConfigNotModified) Decode(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't decode help.appConfigNotModified#7cde641d to nil")
}
if err := b.ConsumeID(HelpAppConfigNotModifiedTypeID); err != nil {
return fmt.Errorf("unable to decode help.appConfigNotModified#7cde641d: %w", err)
}
return a.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (a *HelpAppConfigNotModified) DecodeBare(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't decode help.appConfigNotModified#7cde641d to nil")
}
return nil
}
// HelpAppConfig represents TL type `help.appConfig#dd18782e`.
// Contains various client configuration parameters¹
//
// Links:
// 1. https://core.telegram.org/api/config#client-configuration
//
// See https://core.telegram.org/constructor/help.appConfig for reference.
type HelpAppConfig struct {
// Hash used for caching, for more info click here¹
//
// Links:
// 1) https://core.telegram.org/api/offsets#hash-generation
Hash int
// Client configuration parameters¹
//
// Links:
// 1) https://core.telegram.org/api/config#client-configuration
Config JSONValueClass
}
// HelpAppConfigTypeID is TL type id of HelpAppConfig.
const HelpAppConfigTypeID = 0xdd18782e
// construct implements constructor of HelpAppConfigClass.
func (a HelpAppConfig) construct() HelpAppConfigClass { return &a }
// Ensuring interfaces in compile-time for HelpAppConfig.
var (
_ bin.Encoder = &HelpAppConfig{}
_ bin.Decoder = &HelpAppConfig{}
_ bin.BareEncoder = &HelpAppConfig{}
_ bin.BareDecoder = &HelpAppConfig{}
_ HelpAppConfigClass = &HelpAppConfig{}
)
func (a *HelpAppConfig) Zero() bool {
if a == nil {
return true
}
if !(a.Hash == 0) {
return false
}
if !(a.Config == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (a *HelpAppConfig) String() string {
if a == nil {
return "HelpAppConfig(nil)"
}
type Alias HelpAppConfig
return fmt.Sprintf("HelpAppConfig%+v", Alias(*a))
}
// FillFrom fills HelpAppConfig from given interface.
func (a *HelpAppConfig) FillFrom(from interface {
GetHash() (value int)
GetConfig() (value JSONValueClass)
}) {
a.Hash = from.GetHash()
a.Config = from.GetConfig()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*HelpAppConfig) TypeID() uint32 {
return HelpAppConfigTypeID
}
// TypeName returns name of type in TL schema.
func (*HelpAppConfig) TypeName() string {
return "help.appConfig"
}
// TypeInfo returns info about TL type.
func (a *HelpAppConfig) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "help.appConfig",
ID: HelpAppConfigTypeID,
}
if a == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Hash",
SchemaName: "hash",
},
{
Name: "Config",
SchemaName: "config",
},
}
return typ
}
// Encode implements bin.Encoder.
func (a *HelpAppConfig) Encode(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't encode help.appConfig#dd18782e as nil")
}
b.PutID(HelpAppConfigTypeID)
return a.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (a *HelpAppConfig) EncodeBare(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't encode help.appConfig#dd18782e as nil")
}
b.PutInt(a.Hash)
if a.Config == nil {
return fmt.Errorf("unable to encode help.appConfig#dd18782e: field config is nil")
}
if err := a.Config.Encode(b); err != nil {
return fmt.Errorf("unable to encode help.appConfig#dd18782e: field config: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (a *HelpAppConfig) Decode(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't decode help.appConfig#dd18782e to nil")
}
if err := b.ConsumeID(HelpAppConfigTypeID); err != nil {
return fmt.Errorf("unable to decode help.appConfig#dd18782e: %w", err)
}
return a.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (a *HelpAppConfig) DecodeBare(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't decode help.appConfig#dd18782e to nil")
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode help.appConfig#dd18782e: field hash: %w", err)
}
a.Hash = value
}
{
value, err := DecodeJSONValue(b)
if err != nil {
return fmt.Errorf("unable to decode help.appConfig#dd18782e: field config: %w", err)
}
a.Config = value
}
return nil
}
// GetHash returns value of Hash field.
func (a *HelpAppConfig) GetHash() (value int) {
if a == nil {
return
}
return a.Hash
}
// GetConfig returns value of Config field.
func (a *HelpAppConfig) GetConfig() (value JSONValueClass) {
if a == nil {
return
}
return a.Config
}
// HelpAppConfigClassName is schema name of HelpAppConfigClass.
const HelpAppConfigClassName = "help.AppConfig"
// HelpAppConfigClass represents help.AppConfig generic type.
//
// See https://core.telegram.org/type/help.AppConfig for reference.
//
// Example:
//
// g, err := tg.DecodeHelpAppConfig(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.HelpAppConfigNotModified: // help.appConfigNotModified#7cde641d
// case *tg.HelpAppConfig: // help.appConfig#dd18782e
// default: panic(v)
// }
type HelpAppConfigClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() HelpAppConfigClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
// AsModified tries to map HelpAppConfigClass to HelpAppConfig.
AsModified() (*HelpAppConfig, bool)
}
// AsModified tries to map HelpAppConfigNotModified to HelpAppConfig.
func (a *HelpAppConfigNotModified) AsModified() (*HelpAppConfig, bool) {
return nil, false
}
// AsModified tries to map HelpAppConfig to HelpAppConfig.
func (a *HelpAppConfig) AsModified() (*HelpAppConfig, bool) {
return a, true
}
// DecodeHelpAppConfig implements binary de-serialization for HelpAppConfigClass.
func DecodeHelpAppConfig(buf *bin.Buffer) (HelpAppConfigClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case HelpAppConfigNotModifiedTypeID:
// Decoding help.appConfigNotModified#7cde641d.
v := HelpAppConfigNotModified{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode HelpAppConfigClass: %w", err)
}
return &v, nil
case HelpAppConfigTypeID:
// Decoding help.appConfig#dd18782e.
v := HelpAppConfig{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode HelpAppConfigClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode HelpAppConfigClass: %w", bin.NewUnexpectedID(id))
}
}
// HelpAppConfig boxes the HelpAppConfigClass providing a helper.
type HelpAppConfigBox struct {
AppConfig HelpAppConfigClass
}
// Decode implements bin.Decoder for HelpAppConfigBox.
func (b *HelpAppConfigBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode HelpAppConfigBox to nil")
}
v, err := DecodeHelpAppConfig(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.AppConfig = v
return nil
}
// Encode implements bin.Encode for HelpAppConfigBox.
func (b *HelpAppConfigBox) Encode(buf *bin.Buffer) error {
if b == nil || b.AppConfig == nil {
return fmt.Errorf("unable to encode HelpAppConfigClass as nil")
}
return b.AppConfig.Encode(buf)
}