// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

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

// InputPeerEmpty represents TL type `inputPeerEmpty#7f3b18ea`.
// An empty constructor, no user or chat is defined.
//
// See https://core.telegram.org/constructor/inputPeerEmpty for reference.
type InputPeerEmpty struct {
}

// InputPeerEmptyTypeID is TL type id of InputPeerEmpty.
const InputPeerEmptyTypeID = 0x7f3b18ea

// construct implements constructor of InputPeerClass.
func ( InputPeerEmpty) () InputPeerClass { return & }

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

	_ InputPeerClass = &InputPeerEmpty{}
)

func ( *InputPeerEmpty) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerEmpty",
		ID:   InputPeerEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPeerEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerEmpty#7f3b18ea as nil")
	}
	.PutID(InputPeerEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerEmpty#7f3b18ea as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPeerEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerEmpty#7f3b18ea to nil")
	}
	if  := .ConsumeID(InputPeerEmptyTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPeerEmpty#7f3b18ea: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerEmpty#7f3b18ea to nil")
	}
	return nil
}

// InputPeerSelf represents TL type `inputPeerSelf#7da07ec9`.
// Defines the current user.
//
// See https://core.telegram.org/constructor/inputPeerSelf for reference.
type InputPeerSelf struct {
}

// InputPeerSelfTypeID is TL type id of InputPeerSelf.
const InputPeerSelfTypeID = 0x7da07ec9

// construct implements constructor of InputPeerClass.
func ( InputPeerSelf) () InputPeerClass { return & }

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

	_ InputPeerClass = &InputPeerSelf{}
)

func ( *InputPeerSelf) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerSelf) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerSelf",
		ID:   InputPeerSelfTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPeerSelf) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerSelf#7da07ec9 as nil")
	}
	.PutID(InputPeerSelfTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerSelf) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerSelf#7da07ec9 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPeerSelf) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerSelf#7da07ec9 to nil")
	}
	if  := .ConsumeID(InputPeerSelfTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPeerSelf#7da07ec9: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerSelf) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerSelf#7da07ec9 to nil")
	}
	return nil
}

// InputPeerChat represents TL type `inputPeerChat#35a95cb9`.
// Defines a chat for further interaction.
//
// See https://core.telegram.org/constructor/inputPeerChat for reference.
type InputPeerChat struct {
	// Chat identifier
	ChatID int64
}

// InputPeerChatTypeID is TL type id of InputPeerChat.
const InputPeerChatTypeID = 0x35a95cb9

// construct implements constructor of InputPeerClass.
func ( InputPeerChat) () InputPeerClass { return & }

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

	_ InputPeerClass = &InputPeerChat{}
)

func ( *InputPeerChat) () bool {
	if  == nil {
		return true
	}
	if !(.ChatID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputPeerChat from given interface.
func ( *InputPeerChat) ( interface {
	() ( int64)
}) {
	.ChatID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerChat) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerChat",
		ID:   InputPeerChatTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPeerChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerChat#35a95cb9 as nil")
	}
	.PutID(InputPeerChatTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerChat#35a95cb9 as nil")
	}
	.PutLong(.ChatID)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPeerChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerChat#35a95cb9 to nil")
	}
	if  := .ConsumeID(InputPeerChatTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPeerChat#35a95cb9: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerChat#35a95cb9 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerChat#35a95cb9: field chat_id: %w", )
		}
		.ChatID = 
	}
	return nil
}

// GetChatID returns value of ChatID field.
func ( *InputPeerChat) () ( int64) {
	if  == nil {
		return
	}
	return .ChatID
}

// InputPeerUser represents TL type `inputPeerUser#dde8a54c`.
// Defines a user for further interaction.
//
// See https://core.telegram.org/constructor/inputPeerUser for reference.
type InputPeerUser struct {
	// User identifier
	UserID int64
	// access_hash value from the userĀ¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/constructor/user
	AccessHash int64
}

// InputPeerUserTypeID is TL type id of InputPeerUser.
const InputPeerUserTypeID = 0xdde8a54c

// construct implements constructor of InputPeerClass.
func ( InputPeerUser) () InputPeerClass { return & }

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

	_ InputPeerClass = &InputPeerUser{}
)

func ( *InputPeerUser) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputPeerUser from given interface.
func ( *InputPeerUser) ( interface {
	() ( int64)
	() ( int64)
}) {
	.UserID = .()
	.AccessHash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerUser) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerUser",
		ID:   InputPeerUserTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPeerUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerUser#dde8a54c as nil")
	}
	.PutID(InputPeerUserTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerUser#dde8a54c as nil")
	}
	.PutLong(.UserID)
	.PutLong(.AccessHash)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPeerUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerUser#dde8a54c to nil")
	}
	if  := .ConsumeID(InputPeerUserTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPeerUser#dde8a54c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerUser#dde8a54c to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerUser#dde8a54c: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerUser#dde8a54c: field access_hash: %w", )
		}
		.AccessHash = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *InputPeerUser) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// GetAccessHash returns value of AccessHash field.
func ( *InputPeerUser) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// InputPeerChannel represents TL type `inputPeerChannel#27bcbbfc`.
// Defines a channel for further interaction.
//
// See https://core.telegram.org/constructor/inputPeerChannel for reference.
type InputPeerChannel struct {
	// Channel identifier
	ChannelID int64
	// access_hash value from the channelĀ¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/constructor/channel
	AccessHash int64
}

// InputPeerChannelTypeID is TL type id of InputPeerChannel.
const InputPeerChannelTypeID = 0x27bcbbfc

// construct implements constructor of InputPeerClass.
func ( InputPeerChannel) () InputPeerClass { return & }

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

	_ InputPeerClass = &InputPeerChannel{}
)

func ( *InputPeerChannel) () bool {
	if  == nil {
		return true
	}
	if !(.ChannelID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputPeerChannel from given interface.
func ( *InputPeerChannel) ( interface {
	() ( int64)
	() ( int64)
}) {
	.ChannelID = .()
	.AccessHash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerChannel) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerChannel",
		ID:   InputPeerChannelTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChannelID",
			SchemaName: "channel_id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPeerChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerChannel#27bcbbfc as nil")
	}
	.PutID(InputPeerChannelTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerChannel#27bcbbfc as nil")
	}
	.PutLong(.ChannelID)
	.PutLong(.AccessHash)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPeerChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerChannel#27bcbbfc to nil")
	}
	if  := .ConsumeID(InputPeerChannelTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPeerChannel#27bcbbfc: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerChannel#27bcbbfc to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerChannel#27bcbbfc: field channel_id: %w", )
		}
		.ChannelID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerChannel#27bcbbfc: field access_hash: %w", )
		}
		.AccessHash = 
	}
	return nil
}

// GetChannelID returns value of ChannelID field.
func ( *InputPeerChannel) () ( int64) {
	if  == nil {
		return
	}
	return .ChannelID
}

// GetAccessHash returns value of AccessHash field.
func ( *InputPeerChannel) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// InputPeerUserFromMessage represents TL type `inputPeerUserFromMessage#a87b0a1c`.
// Defines a minĀ¹ user that was seen in a certain message of a certain chat.
//
// Links:
//  1. https://core.telegram.org/api/min
//
// See https://core.telegram.org/constructor/inputPeerUserFromMessage for reference.
type InputPeerUserFromMessage struct {
	// The chat where the user was seen
	Peer InputPeerClass
	// The message ID
	MsgID int
	// The identifier of the user that was seen
	UserID int64
}

// InputPeerUserFromMessageTypeID is TL type id of InputPeerUserFromMessage.
const InputPeerUserFromMessageTypeID = 0xa87b0a1c

// construct implements constructor of InputPeerClass.
func ( InputPeerUserFromMessage) () InputPeerClass { return & }

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

	_ InputPeerClass = &InputPeerUserFromMessage{}
)

func ( *InputPeerUserFromMessage) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputPeerUserFromMessage from given interface.
func ( *InputPeerUserFromMessage) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( int64)
}) {
	.Peer = .()
	.MsgID = .()
	.UserID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerUserFromMessage) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerUserFromMessage",
		ID:   InputPeerUserFromMessageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPeerUserFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerUserFromMessage#a87b0a1c as nil")
	}
	.PutID(InputPeerUserFromMessageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerUserFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerUserFromMessage#a87b0a1c as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode inputPeerUserFromMessage#a87b0a1c: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode inputPeerUserFromMessage#a87b0a1c: field peer: %w", )
	}
	.PutInt(.MsgID)
	.PutLong(.UserID)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPeerUserFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerUserFromMessage#a87b0a1c to nil")
	}
	if  := .ConsumeID(InputPeerUserFromMessageTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPeerUserFromMessage#a87b0a1c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerUserFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerUserFromMessage#a87b0a1c to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerUserFromMessage#a87b0a1c: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerUserFromMessage#a87b0a1c: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerUserFromMessage#a87b0a1c: field user_id: %w", )
		}
		.UserID = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *InputPeerUserFromMessage) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetMsgID returns value of MsgID field.
func ( *InputPeerUserFromMessage) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// GetUserID returns value of UserID field.
func ( *InputPeerUserFromMessage) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// InputPeerChannelFromMessage represents TL type `inputPeerChannelFromMessage#bd2a0840`.
// Defines a minĀ¹ channel that was seen in a certain message of a certain chat.
//
// Links:
//  1. https://core.telegram.org/api/min
//
// See https://core.telegram.org/constructor/inputPeerChannelFromMessage for reference.
type InputPeerChannelFromMessage struct {
	// The chat where the channel's message was seen
	Peer InputPeerClass
	// The message ID
	MsgID int
	// The identifier of the channel that was seen
	ChannelID int64
}

// InputPeerChannelFromMessageTypeID is TL type id of InputPeerChannelFromMessage.
const InputPeerChannelFromMessageTypeID = 0xbd2a0840

// construct implements constructor of InputPeerClass.
func ( InputPeerChannelFromMessage) () InputPeerClass { return & }

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

	_ InputPeerClass = &InputPeerChannelFromMessage{}
)

func ( *InputPeerChannelFromMessage) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.ChannelID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputPeerChannelFromMessage from given interface.
func ( *InputPeerChannelFromMessage) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( int64)
}) {
	.Peer = .()
	.MsgID = .()
	.ChannelID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerChannelFromMessage) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerChannelFromMessage",
		ID:   InputPeerChannelFromMessageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "ChannelID",
			SchemaName: "channel_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPeerChannelFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerChannelFromMessage#bd2a0840 as nil")
	}
	.PutID(InputPeerChannelFromMessageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerChannelFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerChannelFromMessage#bd2a0840 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode inputPeerChannelFromMessage#bd2a0840: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode inputPeerChannelFromMessage#bd2a0840: field peer: %w", )
	}
	.PutInt(.MsgID)
	.PutLong(.ChannelID)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPeerChannelFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerChannelFromMessage#bd2a0840 to nil")
	}
	if  := .ConsumeID(InputPeerChannelFromMessageTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPeerChannelFromMessage#bd2a0840: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerChannelFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerChannelFromMessage#bd2a0840 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerChannelFromMessage#bd2a0840: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerChannelFromMessage#bd2a0840: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerChannelFromMessage#bd2a0840: field channel_id: %w", )
		}
		.ChannelID = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *InputPeerChannelFromMessage) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetMsgID returns value of MsgID field.
func ( *InputPeerChannelFromMessage) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// GetChannelID returns value of ChannelID field.
func ( *InputPeerChannelFromMessage) () ( int64) {
	if  == nil {
		return
	}
	return .ChannelID
}

// InputPeerClassName is schema name of InputPeerClass.
const InputPeerClassName = "InputPeer"

// InputPeerClass represents InputPeer generic type.
//
// See https://core.telegram.org/type/InputPeer for reference.
//
// Example:
//
//	g, err := tg.DecodeInputPeer(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputPeerEmpty: // inputPeerEmpty#7f3b18ea
//	case *tg.InputPeerSelf: // inputPeerSelf#7da07ec9
//	case *tg.InputPeerChat: // inputPeerChat#35a95cb9
//	case *tg.InputPeerUser: // inputPeerUser#dde8a54c
//	case *tg.InputPeerChannel: // inputPeerChannel#27bcbbfc
//	case *tg.InputPeerUserFromMessage: // inputPeerUserFromMessage#a87b0a1c
//	case *tg.InputPeerChannelFromMessage: // inputPeerChannelFromMessage#bd2a0840
//	default: panic(v)
//	}
type InputPeerClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputPeerClass

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

// DecodeInputPeer implements binary de-serialization for InputPeerClass.
func ( *bin.Buffer) (InputPeerClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputPeerEmptyTypeID:
		// Decoding inputPeerEmpty#7f3b18ea.
		 := InputPeerEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPeerClass: %w", )
		}
		return &, nil
	case InputPeerSelfTypeID:
		// Decoding inputPeerSelf#7da07ec9.
		 := InputPeerSelf{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPeerClass: %w", )
		}
		return &, nil
	case InputPeerChatTypeID:
		// Decoding inputPeerChat#35a95cb9.
		 := InputPeerChat{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPeerClass: %w", )
		}
		return &, nil
	case InputPeerUserTypeID:
		// Decoding inputPeerUser#dde8a54c.
		 := InputPeerUser{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPeerClass: %w", )
		}
		return &, nil
	case InputPeerChannelTypeID:
		// Decoding inputPeerChannel#27bcbbfc.
		 := InputPeerChannel{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPeerClass: %w", )
		}
		return &, nil
	case InputPeerUserFromMessageTypeID:
		// Decoding inputPeerUserFromMessage#a87b0a1c.
		 := InputPeerUserFromMessage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPeerClass: %w", )
		}
		return &, nil
	case InputPeerChannelFromMessageTypeID:
		// Decoding inputPeerChannelFromMessage#bd2a0840.
		 := InputPeerChannelFromMessage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPeerClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputPeerClass: %w", bin.NewUnexpectedID())
	}
}

// InputPeer boxes the InputPeerClass providing a helper.
type InputPeerBox struct {
	InputPeer InputPeerClass
}

// Decode implements bin.Decoder for InputPeerBox.
func ( *InputPeerBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode InputPeerBox to nil")
	}
	,  := DecodeInputPeer()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.InputPeer = 
	return nil
}

// Encode implements bin.Encode for InputPeerBox.
func ( *InputPeerBox) ( *bin.Buffer) error {
	if  == nil || .InputPeer == nil {
		return fmt.Errorf("unable to encode InputPeerClass as nil")
	}
	return .InputPeer.Encode()
}