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

432 lines
11 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{}
)
// BlockListMain represents TL type `blockListMain#50a4137c`.
type BlockListMain struct {
}
// BlockListMainTypeID is TL type id of BlockListMain.
const BlockListMainTypeID = 0x50a4137c
// construct implements constructor of BlockListClass.
func (b BlockListMain) construct() BlockListClass { return &b }
// Ensuring interfaces in compile-time for BlockListMain.
var (
_ bin.Encoder = &BlockListMain{}
_ bin.Decoder = &BlockListMain{}
_ bin.BareEncoder = &BlockListMain{}
_ bin.BareDecoder = &BlockListMain{}
_ BlockListClass = &BlockListMain{}
)
func (b *BlockListMain) Zero() bool {
if b == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (b *BlockListMain) String() string {
if b == nil {
return "BlockListMain(nil)"
}
type Alias BlockListMain
return fmt.Sprintf("BlockListMain%+v", Alias(*b))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BlockListMain) TypeID() uint32 {
return BlockListMainTypeID
}
// TypeName returns name of type in TL schema.
func (*BlockListMain) TypeName() string {
return "blockListMain"
}
// TypeInfo returns info about TL type.
func (b *BlockListMain) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "blockListMain",
ID: BlockListMainTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (b *BlockListMain) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode blockListMain#50a4137c as nil")
}
buf.PutID(BlockListMainTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *BlockListMain) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode blockListMain#50a4137c as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (b *BlockListMain) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode blockListMain#50a4137c to nil")
}
if err := buf.ConsumeID(BlockListMainTypeID); err != nil {
return fmt.Errorf("unable to decode blockListMain#50a4137c: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *BlockListMain) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode blockListMain#50a4137c to nil")
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (b *BlockListMain) EncodeTDLibJSON(buf tdjson.Encoder) error {
if b == nil {
return fmt.Errorf("can't encode blockListMain#50a4137c as nil")
}
buf.ObjStart()
buf.PutID("blockListMain")
buf.Comma()
buf.StripComma()
buf.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (b *BlockListMain) DecodeTDLibJSON(buf tdjson.Decoder) error {
if b == nil {
return fmt.Errorf("can't decode blockListMain#50a4137c to nil")
}
return buf.Obj(func(buf tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := buf.ConsumeID("blockListMain"); err != nil {
return fmt.Errorf("unable to decode blockListMain#50a4137c: %w", err)
}
default:
return buf.Skip()
}
return nil
})
}
// BlockListStories represents TL type `blockListStories#628965c`.
type BlockListStories struct {
}
// BlockListStoriesTypeID is TL type id of BlockListStories.
const BlockListStoriesTypeID = 0x628965c
// construct implements constructor of BlockListClass.
func (b BlockListStories) construct() BlockListClass { return &b }
// Ensuring interfaces in compile-time for BlockListStories.
var (
_ bin.Encoder = &BlockListStories{}
_ bin.Decoder = &BlockListStories{}
_ bin.BareEncoder = &BlockListStories{}
_ bin.BareDecoder = &BlockListStories{}
_ BlockListClass = &BlockListStories{}
)
func (b *BlockListStories) Zero() bool {
if b == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (b *BlockListStories) String() string {
if b == nil {
return "BlockListStories(nil)"
}
type Alias BlockListStories
return fmt.Sprintf("BlockListStories%+v", Alias(*b))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BlockListStories) TypeID() uint32 {
return BlockListStoriesTypeID
}
// TypeName returns name of type in TL schema.
func (*BlockListStories) TypeName() string {
return "blockListStories"
}
// TypeInfo returns info about TL type.
func (b *BlockListStories) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "blockListStories",
ID: BlockListStoriesTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (b *BlockListStories) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode blockListStories#628965c as nil")
}
buf.PutID(BlockListStoriesTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *BlockListStories) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode blockListStories#628965c as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (b *BlockListStories) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode blockListStories#628965c to nil")
}
if err := buf.ConsumeID(BlockListStoriesTypeID); err != nil {
return fmt.Errorf("unable to decode blockListStories#628965c: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *BlockListStories) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode blockListStories#628965c to nil")
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (b *BlockListStories) EncodeTDLibJSON(buf tdjson.Encoder) error {
if b == nil {
return fmt.Errorf("can't encode blockListStories#628965c as nil")
}
buf.ObjStart()
buf.PutID("blockListStories")
buf.Comma()
buf.StripComma()
buf.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (b *BlockListStories) DecodeTDLibJSON(buf tdjson.Decoder) error {
if b == nil {
return fmt.Errorf("can't decode blockListStories#628965c to nil")
}
return buf.Obj(func(buf tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := buf.ConsumeID("blockListStories"); err != nil {
return fmt.Errorf("unable to decode blockListStories#628965c: %w", err)
}
default:
return buf.Skip()
}
return nil
})
}
// BlockListClassName is schema name of BlockListClass.
const BlockListClassName = "BlockList"
// BlockListClass represents BlockList generic type.
//
// Example:
//
// g, err := tdapi.DecodeBlockList(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tdapi.BlockListMain: // blockListMain#50a4137c
// case *tdapi.BlockListStories: // blockListStories#628965c
// default: panic(v)
// }
type BlockListClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() BlockListClass
// 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
}
// DecodeBlockList implements binary de-serialization for BlockListClass.
func DecodeBlockList(buf *bin.Buffer) (BlockListClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case BlockListMainTypeID:
// Decoding blockListMain#50a4137c.
v := BlockListMain{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode BlockListClass: %w", err)
}
return &v, nil
case BlockListStoriesTypeID:
// Decoding blockListStories#628965c.
v := BlockListStories{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode BlockListClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode BlockListClass: %w", bin.NewUnexpectedID(id))
}
}
// DecodeTDLibJSONBlockList implements binary de-serialization for BlockListClass.
func DecodeTDLibJSONBlockList(buf tdjson.Decoder) (BlockListClass, error) {
id, err := buf.FindTypeID()
if err != nil {
return nil, err
}
switch id {
case "blockListMain":
// Decoding blockListMain#50a4137c.
v := BlockListMain{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode BlockListClass: %w", err)
}
return &v, nil
case "blockListStories":
// Decoding blockListStories#628965c.
v := BlockListStories{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode BlockListClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode BlockListClass: %w", tdjson.NewUnexpectedID(id))
}
}
// BlockList boxes the BlockListClass providing a helper.
type BlockListBox struct {
BlockList BlockListClass
}
// Decode implements bin.Decoder for BlockListBox.
func (b *BlockListBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode BlockListBox to nil")
}
v, err := DecodeBlockList(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.BlockList = v
return nil
}
// Encode implements bin.Encode for BlockListBox.
func (b *BlockListBox) Encode(buf *bin.Buffer) error {
if b == nil || b.BlockList == nil {
return fmt.Errorf("unable to encode BlockListClass as nil")
}
return b.BlockList.Encode(buf)
}
// DecodeTDLibJSON implements bin.Decoder for BlockListBox.
func (b *BlockListBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
if b == nil {
return fmt.Errorf("unable to decode BlockListBox to nil")
}
v, err := DecodeTDLibJSONBlockList(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.BlockList = v
return nil
}
// EncodeTDLibJSON implements bin.Encode for BlockListBox.
func (b *BlockListBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
if b == nil || b.BlockList == nil {
return fmt.Errorf("unable to encode BlockListClass as nil")
}
return b.BlockList.EncodeTDLibJSON(buf)
}