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

578 lines
15 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{}
)
// StickerFormatWebp represents TL type `stickerFormatWebp#8174ef20`.
type StickerFormatWebp struct {
}
// StickerFormatWebpTypeID is TL type id of StickerFormatWebp.
const StickerFormatWebpTypeID = 0x8174ef20
// construct implements constructor of StickerFormatClass.
func (s StickerFormatWebp) construct() StickerFormatClass { return &s }
// Ensuring interfaces in compile-time for StickerFormatWebp.
var (
_ bin.Encoder = &StickerFormatWebp{}
_ bin.Decoder = &StickerFormatWebp{}
_ bin.BareEncoder = &StickerFormatWebp{}
_ bin.BareDecoder = &StickerFormatWebp{}
_ StickerFormatClass = &StickerFormatWebp{}
)
func (s *StickerFormatWebp) Zero() bool {
if s == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (s *StickerFormatWebp) String() string {
if s == nil {
return "StickerFormatWebp(nil)"
}
type Alias StickerFormatWebp
return fmt.Sprintf("StickerFormatWebp%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StickerFormatWebp) TypeID() uint32 {
return StickerFormatWebpTypeID
}
// TypeName returns name of type in TL schema.
func (*StickerFormatWebp) TypeName() string {
return "stickerFormatWebp"
}
// TypeInfo returns info about TL type.
func (s *StickerFormatWebp) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "stickerFormatWebp",
ID: StickerFormatWebpTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (s *StickerFormatWebp) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatWebp#8174ef20 as nil")
}
b.PutID(StickerFormatWebpTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StickerFormatWebp) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatWebp#8174ef20 as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (s *StickerFormatWebp) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatWebp#8174ef20 to nil")
}
if err := b.ConsumeID(StickerFormatWebpTypeID); err != nil {
return fmt.Errorf("unable to decode stickerFormatWebp#8174ef20: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StickerFormatWebp) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatWebp#8174ef20 to nil")
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StickerFormatWebp) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatWebp#8174ef20 as nil")
}
b.ObjStart()
b.PutID("stickerFormatWebp")
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StickerFormatWebp) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatWebp#8174ef20 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("stickerFormatWebp"); err != nil {
return fmt.Errorf("unable to decode stickerFormatWebp#8174ef20: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// StickerFormatTgs represents TL type `stickerFormatTgs#603caaf6`.
type StickerFormatTgs struct {
}
// StickerFormatTgsTypeID is TL type id of StickerFormatTgs.
const StickerFormatTgsTypeID = 0x603caaf6
// construct implements constructor of StickerFormatClass.
func (s StickerFormatTgs) construct() StickerFormatClass { return &s }
// Ensuring interfaces in compile-time for StickerFormatTgs.
var (
_ bin.Encoder = &StickerFormatTgs{}
_ bin.Decoder = &StickerFormatTgs{}
_ bin.BareEncoder = &StickerFormatTgs{}
_ bin.BareDecoder = &StickerFormatTgs{}
_ StickerFormatClass = &StickerFormatTgs{}
)
func (s *StickerFormatTgs) Zero() bool {
if s == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (s *StickerFormatTgs) String() string {
if s == nil {
return "StickerFormatTgs(nil)"
}
type Alias StickerFormatTgs
return fmt.Sprintf("StickerFormatTgs%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StickerFormatTgs) TypeID() uint32 {
return StickerFormatTgsTypeID
}
// TypeName returns name of type in TL schema.
func (*StickerFormatTgs) TypeName() string {
return "stickerFormatTgs"
}
// TypeInfo returns info about TL type.
func (s *StickerFormatTgs) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "stickerFormatTgs",
ID: StickerFormatTgsTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (s *StickerFormatTgs) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatTgs#603caaf6 as nil")
}
b.PutID(StickerFormatTgsTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StickerFormatTgs) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatTgs#603caaf6 as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (s *StickerFormatTgs) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatTgs#603caaf6 to nil")
}
if err := b.ConsumeID(StickerFormatTgsTypeID); err != nil {
return fmt.Errorf("unable to decode stickerFormatTgs#603caaf6: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StickerFormatTgs) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatTgs#603caaf6 to nil")
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StickerFormatTgs) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatTgs#603caaf6 as nil")
}
b.ObjStart()
b.PutID("stickerFormatTgs")
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StickerFormatTgs) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatTgs#603caaf6 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("stickerFormatTgs"); err != nil {
return fmt.Errorf("unable to decode stickerFormatTgs#603caaf6: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// StickerFormatWebm represents TL type `stickerFormatWebm#849bd54f`.
type StickerFormatWebm struct {
}
// StickerFormatWebmTypeID is TL type id of StickerFormatWebm.
const StickerFormatWebmTypeID = 0x849bd54f
// construct implements constructor of StickerFormatClass.
func (s StickerFormatWebm) construct() StickerFormatClass { return &s }
// Ensuring interfaces in compile-time for StickerFormatWebm.
var (
_ bin.Encoder = &StickerFormatWebm{}
_ bin.Decoder = &StickerFormatWebm{}
_ bin.BareEncoder = &StickerFormatWebm{}
_ bin.BareDecoder = &StickerFormatWebm{}
_ StickerFormatClass = &StickerFormatWebm{}
)
func (s *StickerFormatWebm) Zero() bool {
if s == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (s *StickerFormatWebm) String() string {
if s == nil {
return "StickerFormatWebm(nil)"
}
type Alias StickerFormatWebm
return fmt.Sprintf("StickerFormatWebm%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StickerFormatWebm) TypeID() uint32 {
return StickerFormatWebmTypeID
}
// TypeName returns name of type in TL schema.
func (*StickerFormatWebm) TypeName() string {
return "stickerFormatWebm"
}
// TypeInfo returns info about TL type.
func (s *StickerFormatWebm) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "stickerFormatWebm",
ID: StickerFormatWebmTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (s *StickerFormatWebm) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatWebm#849bd54f as nil")
}
b.PutID(StickerFormatWebmTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StickerFormatWebm) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatWebm#849bd54f as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (s *StickerFormatWebm) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatWebm#849bd54f to nil")
}
if err := b.ConsumeID(StickerFormatWebmTypeID); err != nil {
return fmt.Errorf("unable to decode stickerFormatWebm#849bd54f: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StickerFormatWebm) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatWebm#849bd54f to nil")
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StickerFormatWebm) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode stickerFormatWebm#849bd54f as nil")
}
b.ObjStart()
b.PutID("stickerFormatWebm")
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StickerFormatWebm) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode stickerFormatWebm#849bd54f to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("stickerFormatWebm"); err != nil {
return fmt.Errorf("unable to decode stickerFormatWebm#849bd54f: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// StickerFormatClassName is schema name of StickerFormatClass.
const StickerFormatClassName = "StickerFormat"
// StickerFormatClass represents StickerFormat generic type.
//
// Example:
//
// g, err := tdapi.DecodeStickerFormat(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tdapi.StickerFormatWebp: // stickerFormatWebp#8174ef20
// case *tdapi.StickerFormatTgs: // stickerFormatTgs#603caaf6
// case *tdapi.StickerFormatWebm: // stickerFormatWebm#849bd54f
// default: panic(v)
// }
type StickerFormatClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() StickerFormatClass
// 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
EncodeTDLibJSON(b tdjson.Encoder) error
DecodeTDLibJSON(b tdjson.Decoder) error
}
// DecodeStickerFormat implements binary de-serialization for StickerFormatClass.
func DecodeStickerFormat(buf *bin.Buffer) (StickerFormatClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case StickerFormatWebpTypeID:
// Decoding stickerFormatWebp#8174ef20.
v := StickerFormatWebp{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", err)
}
return &v, nil
case StickerFormatTgsTypeID:
// Decoding stickerFormatTgs#603caaf6.
v := StickerFormatTgs{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", err)
}
return &v, nil
case StickerFormatWebmTypeID:
// Decoding stickerFormatWebm#849bd54f.
v := StickerFormatWebm{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", bin.NewUnexpectedID(id))
}
}
// DecodeTDLibJSONStickerFormat implements binary de-serialization for StickerFormatClass.
func DecodeTDLibJSONStickerFormat(buf tdjson.Decoder) (StickerFormatClass, error) {
id, err := buf.FindTypeID()
if err != nil {
return nil, err
}
switch id {
case "stickerFormatWebp":
// Decoding stickerFormatWebp#8174ef20.
v := StickerFormatWebp{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", err)
}
return &v, nil
case "stickerFormatTgs":
// Decoding stickerFormatTgs#603caaf6.
v := StickerFormatTgs{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", err)
}
return &v, nil
case "stickerFormatWebm":
// Decoding stickerFormatWebm#849bd54f.
v := StickerFormatWebm{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode StickerFormatClass: %w", tdjson.NewUnexpectedID(id))
}
}
// StickerFormat boxes the StickerFormatClass providing a helper.
type StickerFormatBox struct {
StickerFormat StickerFormatClass
}
// Decode implements bin.Decoder for StickerFormatBox.
func (b *StickerFormatBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode StickerFormatBox to nil")
}
v, err := DecodeStickerFormat(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.StickerFormat = v
return nil
}
// Encode implements bin.Encode for StickerFormatBox.
func (b *StickerFormatBox) Encode(buf *bin.Buffer) error {
if b == nil || b.StickerFormat == nil {
return fmt.Errorf("unable to encode StickerFormatClass as nil")
}
return b.StickerFormat.Encode(buf)
}
// DecodeTDLibJSON implements bin.Decoder for StickerFormatBox.
func (b *StickerFormatBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
if b == nil {
return fmt.Errorf("unable to decode StickerFormatBox to nil")
}
v, err := DecodeTDLibJSONStickerFormat(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.StickerFormat = v
return nil
}
// EncodeTDLibJSON implements bin.Encode for StickerFormatBox.
func (b *StickerFormatBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
if b == nil || b.StickerFormat == nil {
return fmt.Errorf("unable to encode StickerFormatClass as nil")
}
return b.StickerFormat.EncodeTDLibJSON(buf)
}