// 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{}
)

// MessageSourceChatHistory represents TL type `messageSourceChatHistory#bf02073c`.
type MessageSourceChatHistory struct {
}

// MessageSourceChatHistoryTypeID is TL type id of MessageSourceChatHistory.
const MessageSourceChatHistoryTypeID = 0xbf02073c

// construct implements constructor of MessageSourceClass.
func (m MessageSourceChatHistory) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceChatHistory.
var (
	_ bin.Encoder     = &MessageSourceChatHistory{}
	_ bin.Decoder     = &MessageSourceChatHistory{}
	_ bin.BareEncoder = &MessageSourceChatHistory{}
	_ bin.BareDecoder = &MessageSourceChatHistory{}

	_ MessageSourceClass = &MessageSourceChatHistory{}
)

func (m *MessageSourceChatHistory) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceChatHistory) String() string {
	if m == nil {
		return "MessageSourceChatHistory(nil)"
	}
	type Alias MessageSourceChatHistory
	return fmt.Sprintf("MessageSourceChatHistory%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceChatHistory) TypeID() uint32 {
	return MessageSourceChatHistoryTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceChatHistory) TypeName() string {
	return "messageSourceChatHistory"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceChatHistory) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceChatHistory",
		ID:   MessageSourceChatHistoryTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceChatHistory) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatHistory#bf02073c as nil")
	}
	b.PutID(MessageSourceChatHistoryTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceChatHistory) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatHistory#bf02073c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceChatHistory) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatHistory#bf02073c to nil")
	}
	if err := b.ConsumeID(MessageSourceChatHistoryTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceChatHistory#bf02073c: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceChatHistory) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatHistory#bf02073c to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceChatHistory) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatHistory#bf02073c as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceChatHistory")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceChatHistory) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatHistory#bf02073c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceChatHistory"); err != nil {
				return fmt.Errorf("unable to decode messageSourceChatHistory#bf02073c: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceMessageThreadHistory represents TL type `messageSourceMessageThreadHistory#114f9106`.
type MessageSourceMessageThreadHistory struct {
}

// MessageSourceMessageThreadHistoryTypeID is TL type id of MessageSourceMessageThreadHistory.
const MessageSourceMessageThreadHistoryTypeID = 0x114f9106

// construct implements constructor of MessageSourceClass.
func (m MessageSourceMessageThreadHistory) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceMessageThreadHistory.
var (
	_ bin.Encoder     = &MessageSourceMessageThreadHistory{}
	_ bin.Decoder     = &MessageSourceMessageThreadHistory{}
	_ bin.BareEncoder = &MessageSourceMessageThreadHistory{}
	_ bin.BareDecoder = &MessageSourceMessageThreadHistory{}

	_ MessageSourceClass = &MessageSourceMessageThreadHistory{}
)

func (m *MessageSourceMessageThreadHistory) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceMessageThreadHistory) String() string {
	if m == nil {
		return "MessageSourceMessageThreadHistory(nil)"
	}
	type Alias MessageSourceMessageThreadHistory
	return fmt.Sprintf("MessageSourceMessageThreadHistory%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceMessageThreadHistory) TypeID() uint32 {
	return MessageSourceMessageThreadHistoryTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceMessageThreadHistory) TypeName() string {
	return "messageSourceMessageThreadHistory"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceMessageThreadHistory) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceMessageThreadHistory",
		ID:   MessageSourceMessageThreadHistoryTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceMessageThreadHistory) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceMessageThreadHistory#114f9106 as nil")
	}
	b.PutID(MessageSourceMessageThreadHistoryTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceMessageThreadHistory) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceMessageThreadHistory#114f9106 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceMessageThreadHistory) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceMessageThreadHistory#114f9106 to nil")
	}
	if err := b.ConsumeID(MessageSourceMessageThreadHistoryTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceMessageThreadHistory#114f9106: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceMessageThreadHistory) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceMessageThreadHistory#114f9106 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceMessageThreadHistory) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceMessageThreadHistory#114f9106 as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceMessageThreadHistory")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceMessageThreadHistory) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceMessageThreadHistory#114f9106 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceMessageThreadHistory"); err != nil {
				return fmt.Errorf("unable to decode messageSourceMessageThreadHistory#114f9106: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceForumTopicHistory represents TL type `messageSourceForumTopicHistory#a5842cb7`.
type MessageSourceForumTopicHistory struct {
}

// MessageSourceForumTopicHistoryTypeID is TL type id of MessageSourceForumTopicHistory.
const MessageSourceForumTopicHistoryTypeID = 0xa5842cb7

// construct implements constructor of MessageSourceClass.
func (m MessageSourceForumTopicHistory) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceForumTopicHistory.
var (
	_ bin.Encoder     = &MessageSourceForumTopicHistory{}
	_ bin.Decoder     = &MessageSourceForumTopicHistory{}
	_ bin.BareEncoder = &MessageSourceForumTopicHistory{}
	_ bin.BareDecoder = &MessageSourceForumTopicHistory{}

	_ MessageSourceClass = &MessageSourceForumTopicHistory{}
)

func (m *MessageSourceForumTopicHistory) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceForumTopicHistory) String() string {
	if m == nil {
		return "MessageSourceForumTopicHistory(nil)"
	}
	type Alias MessageSourceForumTopicHistory
	return fmt.Sprintf("MessageSourceForumTopicHistory%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceForumTopicHistory) TypeID() uint32 {
	return MessageSourceForumTopicHistoryTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceForumTopicHistory) TypeName() string {
	return "messageSourceForumTopicHistory"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceForumTopicHistory) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceForumTopicHistory",
		ID:   MessageSourceForumTopicHistoryTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceForumTopicHistory) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceForumTopicHistory#a5842cb7 as nil")
	}
	b.PutID(MessageSourceForumTopicHistoryTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceForumTopicHistory) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceForumTopicHistory#a5842cb7 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceForumTopicHistory) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceForumTopicHistory#a5842cb7 to nil")
	}
	if err := b.ConsumeID(MessageSourceForumTopicHistoryTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceForumTopicHistory#a5842cb7: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceForumTopicHistory) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceForumTopicHistory#a5842cb7 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceForumTopicHistory) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceForumTopicHistory#a5842cb7 as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceForumTopicHistory")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceForumTopicHistory) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceForumTopicHistory#a5842cb7 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceForumTopicHistory"); err != nil {
				return fmt.Errorf("unable to decode messageSourceForumTopicHistory#a5842cb7: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceDirectMessagesChatTopicHistory represents TL type `messageSourceDirectMessagesChatTopicHistory#6f6a9737`.
type MessageSourceDirectMessagesChatTopicHistory struct {
}

// MessageSourceDirectMessagesChatTopicHistoryTypeID is TL type id of MessageSourceDirectMessagesChatTopicHistory.
const MessageSourceDirectMessagesChatTopicHistoryTypeID = 0x6f6a9737

// construct implements constructor of MessageSourceClass.
func (m MessageSourceDirectMessagesChatTopicHistory) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceDirectMessagesChatTopicHistory.
var (
	_ bin.Encoder     = &MessageSourceDirectMessagesChatTopicHistory{}
	_ bin.Decoder     = &MessageSourceDirectMessagesChatTopicHistory{}
	_ bin.BareEncoder = &MessageSourceDirectMessagesChatTopicHistory{}
	_ bin.BareDecoder = &MessageSourceDirectMessagesChatTopicHistory{}

	_ MessageSourceClass = &MessageSourceDirectMessagesChatTopicHistory{}
)

func (m *MessageSourceDirectMessagesChatTopicHistory) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceDirectMessagesChatTopicHistory) String() string {
	if m == nil {
		return "MessageSourceDirectMessagesChatTopicHistory(nil)"
	}
	type Alias MessageSourceDirectMessagesChatTopicHistory
	return fmt.Sprintf("MessageSourceDirectMessagesChatTopicHistory%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceDirectMessagesChatTopicHistory) TypeID() uint32 {
	return MessageSourceDirectMessagesChatTopicHistoryTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceDirectMessagesChatTopicHistory) TypeName() string {
	return "messageSourceDirectMessagesChatTopicHistory"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceDirectMessagesChatTopicHistory) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceDirectMessagesChatTopicHistory",
		ID:   MessageSourceDirectMessagesChatTopicHistoryTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceDirectMessagesChatTopicHistory) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceDirectMessagesChatTopicHistory#6f6a9737 as nil")
	}
	b.PutID(MessageSourceDirectMessagesChatTopicHistoryTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceDirectMessagesChatTopicHistory) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceDirectMessagesChatTopicHistory#6f6a9737 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceDirectMessagesChatTopicHistory) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceDirectMessagesChatTopicHistory#6f6a9737 to nil")
	}
	if err := b.ConsumeID(MessageSourceDirectMessagesChatTopicHistoryTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceDirectMessagesChatTopicHistory#6f6a9737: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceDirectMessagesChatTopicHistory) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceDirectMessagesChatTopicHistory#6f6a9737 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceDirectMessagesChatTopicHistory) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceDirectMessagesChatTopicHistory#6f6a9737 as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceDirectMessagesChatTopicHistory")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceDirectMessagesChatTopicHistory) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceDirectMessagesChatTopicHistory#6f6a9737 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceDirectMessagesChatTopicHistory"); err != nil {
				return fmt.Errorf("unable to decode messageSourceDirectMessagesChatTopicHistory#6f6a9737: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceHistoryPreview represents TL type `messageSourceHistoryPreview#3d0ce411`.
type MessageSourceHistoryPreview struct {
}

// MessageSourceHistoryPreviewTypeID is TL type id of MessageSourceHistoryPreview.
const MessageSourceHistoryPreviewTypeID = 0x3d0ce411

// construct implements constructor of MessageSourceClass.
func (m MessageSourceHistoryPreview) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceHistoryPreview.
var (
	_ bin.Encoder     = &MessageSourceHistoryPreview{}
	_ bin.Decoder     = &MessageSourceHistoryPreview{}
	_ bin.BareEncoder = &MessageSourceHistoryPreview{}
	_ bin.BareDecoder = &MessageSourceHistoryPreview{}

	_ MessageSourceClass = &MessageSourceHistoryPreview{}
)

func (m *MessageSourceHistoryPreview) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceHistoryPreview) String() string {
	if m == nil {
		return "MessageSourceHistoryPreview(nil)"
	}
	type Alias MessageSourceHistoryPreview
	return fmt.Sprintf("MessageSourceHistoryPreview%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceHistoryPreview) TypeID() uint32 {
	return MessageSourceHistoryPreviewTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceHistoryPreview) TypeName() string {
	return "messageSourceHistoryPreview"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceHistoryPreview) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceHistoryPreview",
		ID:   MessageSourceHistoryPreviewTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceHistoryPreview) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceHistoryPreview#3d0ce411 as nil")
	}
	b.PutID(MessageSourceHistoryPreviewTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceHistoryPreview) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceHistoryPreview#3d0ce411 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceHistoryPreview) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceHistoryPreview#3d0ce411 to nil")
	}
	if err := b.ConsumeID(MessageSourceHistoryPreviewTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceHistoryPreview#3d0ce411: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceHistoryPreview) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceHistoryPreview#3d0ce411 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceHistoryPreview) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceHistoryPreview#3d0ce411 as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceHistoryPreview")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceHistoryPreview) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceHistoryPreview#3d0ce411 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceHistoryPreview"); err != nil {
				return fmt.Errorf("unable to decode messageSourceHistoryPreview#3d0ce411: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceChatList represents TL type `messageSourceChatList#85f70fea`.
type MessageSourceChatList struct {
}

// MessageSourceChatListTypeID is TL type id of MessageSourceChatList.
const MessageSourceChatListTypeID = 0x85f70fea

// construct implements constructor of MessageSourceClass.
func (m MessageSourceChatList) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceChatList.
var (
	_ bin.Encoder     = &MessageSourceChatList{}
	_ bin.Decoder     = &MessageSourceChatList{}
	_ bin.BareEncoder = &MessageSourceChatList{}
	_ bin.BareDecoder = &MessageSourceChatList{}

	_ MessageSourceClass = &MessageSourceChatList{}
)

func (m *MessageSourceChatList) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceChatList) String() string {
	if m == nil {
		return "MessageSourceChatList(nil)"
	}
	type Alias MessageSourceChatList
	return fmt.Sprintf("MessageSourceChatList%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceChatList) TypeID() uint32 {
	return MessageSourceChatListTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceChatList) TypeName() string {
	return "messageSourceChatList"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceChatList) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceChatList",
		ID:   MessageSourceChatListTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceChatList) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatList#85f70fea as nil")
	}
	b.PutID(MessageSourceChatListTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceChatList) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatList#85f70fea as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceChatList) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatList#85f70fea to nil")
	}
	if err := b.ConsumeID(MessageSourceChatListTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceChatList#85f70fea: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceChatList) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatList#85f70fea to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceChatList) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatList#85f70fea as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceChatList")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceChatList) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatList#85f70fea to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceChatList"); err != nil {
				return fmt.Errorf("unable to decode messageSourceChatList#85f70fea: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceSearch represents TL type `messageSourceSearch#72853771`.
type MessageSourceSearch struct {
}

// MessageSourceSearchTypeID is TL type id of MessageSourceSearch.
const MessageSourceSearchTypeID = 0x72853771

// construct implements constructor of MessageSourceClass.
func (m MessageSourceSearch) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceSearch.
var (
	_ bin.Encoder     = &MessageSourceSearch{}
	_ bin.Decoder     = &MessageSourceSearch{}
	_ bin.BareEncoder = &MessageSourceSearch{}
	_ bin.BareDecoder = &MessageSourceSearch{}

	_ MessageSourceClass = &MessageSourceSearch{}
)

func (m *MessageSourceSearch) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceSearch) String() string {
	if m == nil {
		return "MessageSourceSearch(nil)"
	}
	type Alias MessageSourceSearch
	return fmt.Sprintf("MessageSourceSearch%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceSearch) TypeID() uint32 {
	return MessageSourceSearchTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceSearch) TypeName() string {
	return "messageSourceSearch"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceSearch) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceSearch",
		ID:   MessageSourceSearchTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceSearch) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceSearch#72853771 as nil")
	}
	b.PutID(MessageSourceSearchTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceSearch) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceSearch#72853771 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceSearch) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceSearch#72853771 to nil")
	}
	if err := b.ConsumeID(MessageSourceSearchTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceSearch#72853771: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceSearch) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceSearch#72853771 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceSearch) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceSearch#72853771 as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceSearch")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceSearch) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceSearch#72853771 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceSearch"); err != nil {
				return fmt.Errorf("unable to decode messageSourceSearch#72853771: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceChatEventLog represents TL type `messageSourceChatEventLog#c2ae19bc`.
type MessageSourceChatEventLog struct {
}

// MessageSourceChatEventLogTypeID is TL type id of MessageSourceChatEventLog.
const MessageSourceChatEventLogTypeID = 0xc2ae19bc

// construct implements constructor of MessageSourceClass.
func (m MessageSourceChatEventLog) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceChatEventLog.
var (
	_ bin.Encoder     = &MessageSourceChatEventLog{}
	_ bin.Decoder     = &MessageSourceChatEventLog{}
	_ bin.BareEncoder = &MessageSourceChatEventLog{}
	_ bin.BareDecoder = &MessageSourceChatEventLog{}

	_ MessageSourceClass = &MessageSourceChatEventLog{}
)

func (m *MessageSourceChatEventLog) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceChatEventLog) String() string {
	if m == nil {
		return "MessageSourceChatEventLog(nil)"
	}
	type Alias MessageSourceChatEventLog
	return fmt.Sprintf("MessageSourceChatEventLog%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceChatEventLog) TypeID() uint32 {
	return MessageSourceChatEventLogTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceChatEventLog) TypeName() string {
	return "messageSourceChatEventLog"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceChatEventLog) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceChatEventLog",
		ID:   MessageSourceChatEventLogTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceChatEventLog) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatEventLog#c2ae19bc as nil")
	}
	b.PutID(MessageSourceChatEventLogTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceChatEventLog) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatEventLog#c2ae19bc as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceChatEventLog) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatEventLog#c2ae19bc to nil")
	}
	if err := b.ConsumeID(MessageSourceChatEventLogTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceChatEventLog#c2ae19bc: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceChatEventLog) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatEventLog#c2ae19bc to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceChatEventLog) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceChatEventLog#c2ae19bc as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceChatEventLog")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceChatEventLog) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceChatEventLog#c2ae19bc to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceChatEventLog"); err != nil {
				return fmt.Errorf("unable to decode messageSourceChatEventLog#c2ae19bc: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceNotification represents TL type `messageSourceNotification#c1a11bed`.
type MessageSourceNotification struct {
}

// MessageSourceNotificationTypeID is TL type id of MessageSourceNotification.
const MessageSourceNotificationTypeID = 0xc1a11bed

// construct implements constructor of MessageSourceClass.
func (m MessageSourceNotification) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceNotification.
var (
	_ bin.Encoder     = &MessageSourceNotification{}
	_ bin.Decoder     = &MessageSourceNotification{}
	_ bin.BareEncoder = &MessageSourceNotification{}
	_ bin.BareDecoder = &MessageSourceNotification{}

	_ MessageSourceClass = &MessageSourceNotification{}
)

func (m *MessageSourceNotification) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceNotification) String() string {
	if m == nil {
		return "MessageSourceNotification(nil)"
	}
	type Alias MessageSourceNotification
	return fmt.Sprintf("MessageSourceNotification%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceNotification) TypeID() uint32 {
	return MessageSourceNotificationTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceNotification) TypeName() string {
	return "messageSourceNotification"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceNotification) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceNotification",
		ID:   MessageSourceNotificationTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceNotification) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceNotification#c1a11bed as nil")
	}
	b.PutID(MessageSourceNotificationTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceNotification) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceNotification#c1a11bed as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceNotification) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceNotification#c1a11bed to nil")
	}
	if err := b.ConsumeID(MessageSourceNotificationTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceNotification#c1a11bed: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceNotification) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceNotification#c1a11bed to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceNotification) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceNotification#c1a11bed as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceNotification")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceNotification) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceNotification#c1a11bed to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceNotification"); err != nil {
				return fmt.Errorf("unable to decode messageSourceNotification#c1a11bed: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceScreenshot represents TL type `messageSourceScreenshot#1c035d0a`.
type MessageSourceScreenshot struct {
}

// MessageSourceScreenshotTypeID is TL type id of MessageSourceScreenshot.
const MessageSourceScreenshotTypeID = 0x1c035d0a

// construct implements constructor of MessageSourceClass.
func (m MessageSourceScreenshot) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceScreenshot.
var (
	_ bin.Encoder     = &MessageSourceScreenshot{}
	_ bin.Decoder     = &MessageSourceScreenshot{}
	_ bin.BareEncoder = &MessageSourceScreenshot{}
	_ bin.BareDecoder = &MessageSourceScreenshot{}

	_ MessageSourceClass = &MessageSourceScreenshot{}
)

func (m *MessageSourceScreenshot) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceScreenshot) String() string {
	if m == nil {
		return "MessageSourceScreenshot(nil)"
	}
	type Alias MessageSourceScreenshot
	return fmt.Sprintf("MessageSourceScreenshot%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceScreenshot) TypeID() uint32 {
	return MessageSourceScreenshotTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceScreenshot) TypeName() string {
	return "messageSourceScreenshot"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceScreenshot) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceScreenshot",
		ID:   MessageSourceScreenshotTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceScreenshot) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceScreenshot#1c035d0a as nil")
	}
	b.PutID(MessageSourceScreenshotTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceScreenshot) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceScreenshot#1c035d0a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceScreenshot) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceScreenshot#1c035d0a to nil")
	}
	if err := b.ConsumeID(MessageSourceScreenshotTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceScreenshot#1c035d0a: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceScreenshot) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceScreenshot#1c035d0a to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceScreenshot) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceScreenshot#1c035d0a as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceScreenshot")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceScreenshot) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceScreenshot#1c035d0a to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceScreenshot"); err != nil {
				return fmt.Errorf("unable to decode messageSourceScreenshot#1c035d0a: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceOther represents TL type `messageSourceOther#35c0a702`.
type MessageSourceOther struct {
}

// MessageSourceOtherTypeID is TL type id of MessageSourceOther.
const MessageSourceOtherTypeID = 0x35c0a702

// construct implements constructor of MessageSourceClass.
func (m MessageSourceOther) construct() MessageSourceClass { return &m }

// Ensuring interfaces in compile-time for MessageSourceOther.
var (
	_ bin.Encoder     = &MessageSourceOther{}
	_ bin.Decoder     = &MessageSourceOther{}
	_ bin.BareEncoder = &MessageSourceOther{}
	_ bin.BareDecoder = &MessageSourceOther{}

	_ MessageSourceClass = &MessageSourceOther{}
)

func (m *MessageSourceOther) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (m *MessageSourceOther) String() string {
	if m == nil {
		return "MessageSourceOther(nil)"
	}
	type Alias MessageSourceOther
	return fmt.Sprintf("MessageSourceOther%+v", Alias(*m))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageSourceOther) TypeID() uint32 {
	return MessageSourceOtherTypeID
}

// TypeName returns name of type in TL schema.
func (*MessageSourceOther) TypeName() string {
	return "messageSourceOther"
}

// TypeInfo returns info about TL type.
func (m *MessageSourceOther) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageSourceOther",
		ID:   MessageSourceOtherTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageSourceOther) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceOther#35c0a702 as nil")
	}
	b.PutID(MessageSourceOtherTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageSourceOther) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceOther#35c0a702 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageSourceOther) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceOther#35c0a702 to nil")
	}
	if err := b.ConsumeID(MessageSourceOtherTypeID); err != nil {
		return fmt.Errorf("unable to decode messageSourceOther#35c0a702: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageSourceOther) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceOther#35c0a702 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageSourceOther) EncodeTDLibJSON(b tdjson.Encoder) error {
	if m == nil {
		return fmt.Errorf("can't encode messageSourceOther#35c0a702 as nil")
	}
	b.ObjStart()
	b.PutID("messageSourceOther")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageSourceOther) DecodeTDLibJSON(b tdjson.Decoder) error {
	if m == nil {
		return fmt.Errorf("can't decode messageSourceOther#35c0a702 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("messageSourceOther"); err != nil {
				return fmt.Errorf("unable to decode messageSourceOther#35c0a702: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// MessageSourceClassName is schema name of MessageSourceClass.
const MessageSourceClassName = "MessageSource"

// MessageSourceClass represents MessageSource generic type.
//
// Example:
//
//	g, err := tdapi.DecodeMessageSource(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.MessageSourceChatHistory: // messageSourceChatHistory#bf02073c
//	case *tdapi.MessageSourceMessageThreadHistory: // messageSourceMessageThreadHistory#114f9106
//	case *tdapi.MessageSourceForumTopicHistory: // messageSourceForumTopicHistory#a5842cb7
//	case *tdapi.MessageSourceDirectMessagesChatTopicHistory: // messageSourceDirectMessagesChatTopicHistory#6f6a9737
//	case *tdapi.MessageSourceHistoryPreview: // messageSourceHistoryPreview#3d0ce411
//	case *tdapi.MessageSourceChatList: // messageSourceChatList#85f70fea
//	case *tdapi.MessageSourceSearch: // messageSourceSearch#72853771
//	case *tdapi.MessageSourceChatEventLog: // messageSourceChatEventLog#c2ae19bc
//	case *tdapi.MessageSourceNotification: // messageSourceNotification#c1a11bed
//	case *tdapi.MessageSourceScreenshot: // messageSourceScreenshot#1c035d0a
//	case *tdapi.MessageSourceOther: // messageSourceOther#35c0a702
//	default: panic(v)
//	}
type MessageSourceClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessageSourceClass

	// 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
}

// DecodeMessageSource implements binary de-serialization for MessageSourceClass.
func DecodeMessageSource(buf *bin.Buffer) (MessageSourceClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case MessageSourceChatHistoryTypeID:
		// Decoding messageSourceChatHistory#bf02073c.
		v := MessageSourceChatHistory{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceMessageThreadHistoryTypeID:
		// Decoding messageSourceMessageThreadHistory#114f9106.
		v := MessageSourceMessageThreadHistory{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceForumTopicHistoryTypeID:
		// Decoding messageSourceForumTopicHistory#a5842cb7.
		v := MessageSourceForumTopicHistory{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceDirectMessagesChatTopicHistoryTypeID:
		// Decoding messageSourceDirectMessagesChatTopicHistory#6f6a9737.
		v := MessageSourceDirectMessagesChatTopicHistory{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceHistoryPreviewTypeID:
		// Decoding messageSourceHistoryPreview#3d0ce411.
		v := MessageSourceHistoryPreview{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceChatListTypeID:
		// Decoding messageSourceChatList#85f70fea.
		v := MessageSourceChatList{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceSearchTypeID:
		// Decoding messageSourceSearch#72853771.
		v := MessageSourceSearch{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceChatEventLogTypeID:
		// Decoding messageSourceChatEventLog#c2ae19bc.
		v := MessageSourceChatEventLog{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceNotificationTypeID:
		// Decoding messageSourceNotification#c1a11bed.
		v := MessageSourceNotification{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceScreenshotTypeID:
		// Decoding messageSourceScreenshot#1c035d0a.
		v := MessageSourceScreenshot{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case MessageSourceOtherTypeID:
		// Decoding messageSourceOther#35c0a702.
		v := MessageSourceOther{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONMessageSource implements binary de-serialization for MessageSourceClass.
func DecodeTDLibJSONMessageSource(buf tdjson.Decoder) (MessageSourceClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "messageSourceChatHistory":
		// Decoding messageSourceChatHistory#bf02073c.
		v := MessageSourceChatHistory{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceMessageThreadHistory":
		// Decoding messageSourceMessageThreadHistory#114f9106.
		v := MessageSourceMessageThreadHistory{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceForumTopicHistory":
		// Decoding messageSourceForumTopicHistory#a5842cb7.
		v := MessageSourceForumTopicHistory{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceDirectMessagesChatTopicHistory":
		// Decoding messageSourceDirectMessagesChatTopicHistory#6f6a9737.
		v := MessageSourceDirectMessagesChatTopicHistory{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceHistoryPreview":
		// Decoding messageSourceHistoryPreview#3d0ce411.
		v := MessageSourceHistoryPreview{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceChatList":
		// Decoding messageSourceChatList#85f70fea.
		v := MessageSourceChatList{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceSearch":
		// Decoding messageSourceSearch#72853771.
		v := MessageSourceSearch{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceChatEventLog":
		// Decoding messageSourceChatEventLog#c2ae19bc.
		v := MessageSourceChatEventLog{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceNotification":
		// Decoding messageSourceNotification#c1a11bed.
		v := MessageSourceNotification{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceScreenshot":
		// Decoding messageSourceScreenshot#1c035d0a.
		v := MessageSourceScreenshot{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	case "messageSourceOther":
		// Decoding messageSourceOther#35c0a702.
		v := MessageSourceOther{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode MessageSourceClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// MessageSource boxes the MessageSourceClass providing a helper.
type MessageSourceBox struct {
	MessageSource MessageSourceClass
}

// Decode implements bin.Decoder for MessageSourceBox.
func (b *MessageSourceBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode MessageSourceBox to nil")
	}
	v, err := DecodeMessageSource(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.MessageSource = v
	return nil
}

// Encode implements bin.Encode for MessageSourceBox.
func (b *MessageSourceBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.MessageSource == nil {
		return fmt.Errorf("unable to encode MessageSourceClass as nil")
	}
	return b.MessageSource.Encode(buf)
}

// DecodeTDLibJSON implements bin.Decoder for MessageSourceBox.
func (b *MessageSourceBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
	if b == nil {
		return fmt.Errorf("unable to decode MessageSourceBox to nil")
	}
	v, err := DecodeTDLibJSONMessageSource(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.MessageSource = v
	return nil
}

// EncodeTDLibJSON implements bin.Encode for MessageSourceBox.
func (b *MessageSourceBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
	if b == nil || b.MessageSource == nil {
		return fmt.Errorf("unable to encode MessageSourceClass as nil")
	}
	return b.MessageSource.EncodeTDLibJSON(buf)
}
