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

// InputChannelEmpty represents TL type `inputChannelEmpty#ee8c1e86`.
// Represents the absence of a channel
//
// See https://core.telegram.org/constructor/inputChannelEmpty for reference.
type InputChannelEmpty struct {
}

// InputChannelEmptyTypeID is TL type id of InputChannelEmpty.
const InputChannelEmptyTypeID = 0xee8c1e86

// construct implements constructor of InputChannelClass.
func ( InputChannelEmpty) () InputChannelClass { return & }

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

	_ InputChannelClass = &InputChannelEmpty{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputChannelEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChannelEmpty#ee8c1e86 as nil")
	}
	.PutID(InputChannelEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputChannelEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChannelEmpty#ee8c1e86 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputChannelEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputChannelEmpty#ee8c1e86 to nil")
	}
	return nil
}

// InputChannel represents TL type `inputChannel#f35aec28`.
// Represents a channel
//
// See https://core.telegram.org/constructor/inputChannel for reference.
type InputChannel struct {
	// Channel ID
	ChannelID int64
	// Access hash taken from the channelĀ¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/constructor/channel
	AccessHash int64
}

// InputChannelTypeID is TL type id of InputChannel.
const InputChannelTypeID = 0xf35aec28

// construct implements constructor of InputChannelClass.
func ( InputChannel) () InputChannelClass { return & }

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

	_ InputChannelClass = &InputChannel{}
)

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChannel#f35aec28 as nil")
	}
	.PutID(InputChannelTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// InputChannelFromMessage represents TL type `inputChannelFromMessage#5b934f9d`.
// 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/inputChannelFromMessage for reference.
type InputChannelFromMessage struct {
	// The chat where the channel was seen
	Peer InputPeerClass
	// The message ID in the chat where the channel was seen
	MsgID int
	// The channel ID
	ChannelID int64
}

// InputChannelFromMessageTypeID is TL type id of InputChannelFromMessage.
const InputChannelFromMessageTypeID = 0x5b934f9d

// construct implements constructor of InputChannelClass.
func ( InputChannelFromMessage) () InputChannelClass { return & }

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

	_ InputChannelClass = &InputChannelFromMessage{}
)

func ( *InputChannelFromMessage) () 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 ( *InputChannelFromMessage) () string {
	if  == nil {
		return "InputChannelFromMessage(nil)"
	}
	type  InputChannelFromMessage
	return fmt.Sprintf("InputChannelFromMessage%+v", (*))
}

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

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

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

// TypeInfo returns info about TL type.
func ( *InputChannelFromMessage) () tdp.Type {
	 := tdp.Type{
		Name: "inputChannelFromMessage",
		ID:   InputChannelFromMessageTypeID,
	}
	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 ( *InputChannelFromMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChannelFromMessage#5b934f9d as nil")
	}
	.PutID(InputChannelFromMessageTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

// InputChannelClassName is schema name of InputChannelClass.
const InputChannelClassName = "InputChannel"

// InputChannelClass represents InputChannel generic type.
//
// See https://core.telegram.org/type/InputChannel for reference.
//
// Example:
//
//	g, err := tg.DecodeInputChannel(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputChannelEmpty: // inputChannelEmpty#ee8c1e86
//	case *tg.InputChannel: // inputChannel#f35aec28
//	case *tg.InputChannelFromMessage: // inputChannelFromMessage#5b934f9d
//	default: panic(v)
//	}
type InputChannelClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputChannelClass

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

	// AsNotEmpty tries to map InputChannelClass to NotEmptyInputChannel.
	AsNotEmpty() (NotEmptyInputChannel, bool)
}

// NotEmptyInputChannel represents NotEmpty subset of InputChannelClass.
type NotEmptyInputChannel interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputChannelClass

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

	// Channel ID
	GetChannelID() (value int64)
}

// AsNotEmpty tries to map InputChannelEmpty to NotEmptyInputChannel.
func ( *InputChannelEmpty) () (NotEmptyInputChannel, bool) {
	,  := (InputChannelClass()).(NotEmptyInputChannel)
	return , 
}

// AsNotEmpty tries to map InputChannel to NotEmptyInputChannel.
func ( *InputChannel) () (NotEmptyInputChannel, bool) {
	,  := (InputChannelClass()).(NotEmptyInputChannel)
	return , 
}

// AsNotEmpty tries to map InputChannelFromMessage to NotEmptyInputChannel.
func ( *InputChannelFromMessage) () (NotEmptyInputChannel, bool) {
	,  := (InputChannelClass()).(NotEmptyInputChannel)
	return , 
}

// DecodeInputChannel implements binary de-serialization for InputChannelClass.
func ( *bin.Buffer) (InputChannelClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputChannelEmptyTypeID:
		// Decoding inputChannelEmpty#ee8c1e86.
		 := InputChannelEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputChannelClass: %w", )
		}
		return &, nil
	case InputChannelTypeID:
		// Decoding inputChannel#f35aec28.
		 := InputChannel{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputChannelClass: %w", )
		}
		return &, nil
	case InputChannelFromMessageTypeID:
		// Decoding inputChannelFromMessage#5b934f9d.
		 := InputChannelFromMessage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputChannelClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputChannelClass: %w", bin.NewUnexpectedID())
	}
}

// InputChannel boxes the InputChannelClass providing a helper.
type InputChannelBox struct {
	InputChannel InputChannelClass
}

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

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