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

// InputDialogPeer represents TL type `inputDialogPeer#fcaafeb7`.
// A peer
//
// See https://core.telegram.org/constructor/inputDialogPeer for reference.
type InputDialogPeer struct {
	// Peer
	Peer InputPeerClass
}

// InputDialogPeerTypeID is TL type id of InputDialogPeer.
const InputDialogPeerTypeID = 0xfcaafeb7

// construct implements constructor of InputDialogPeerClass.
func ( InputDialogPeer) () InputDialogPeerClass { return & }

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

	_ InputDialogPeerClass = &InputDialogPeer{}
)

func ( *InputDialogPeer) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputDialogPeer from given interface.
func ( *InputDialogPeer) ( interface {
	() ( InputPeerClass)
}) {
	.Peer = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputDialogPeer) () tdp.Type {
	 := tdp.Type{
		Name: "inputDialogPeer",
		ID:   InputDialogPeerTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputDialogPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputDialogPeer#fcaafeb7 as nil")
	}
	.PutID(InputDialogPeerTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *InputDialogPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputDialogPeer#fcaafeb7 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputDialogPeer#fcaafeb7: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

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

// InputDialogPeerFolder represents TL type `inputDialogPeerFolder#64600527`.
// All peers in a peer folderĀ¹
//
// Links:
//  1. https://core.telegram.org/api/folders#peer-folders
//
// See https://core.telegram.org/constructor/inputDialogPeerFolder for reference.
type InputDialogPeerFolder struct {
	// Peer folder ID, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders#peer-folders
	FolderID int
}

// InputDialogPeerFolderTypeID is TL type id of InputDialogPeerFolder.
const InputDialogPeerFolderTypeID = 0x64600527

// construct implements constructor of InputDialogPeerClass.
func ( InputDialogPeerFolder) () InputDialogPeerClass { return & }

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

	_ InputDialogPeerClass = &InputDialogPeerFolder{}
)

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

	return true
}

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

// FillFrom fills InputDialogPeerFolder from given interface.
func ( *InputDialogPeerFolder) ( interface {
	() ( int)
}) {
	.FolderID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputDialogPeerFolder) () tdp.Type {
	 := tdp.Type{
		Name: "inputDialogPeerFolder",
		ID:   InputDialogPeerFolderTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FolderID",
			SchemaName: "folder_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputDialogPeerFolder) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputDialogPeerFolder#64600527 as nil")
	}
	.PutID(InputDialogPeerFolderTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputDialogPeerFolder) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputDialogPeerFolder#64600527 as nil")
	}
	.PutInt(.FolderID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputDialogPeerFolder) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputDialogPeerFolder#64600527 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputDialogPeerFolder#64600527: field folder_id: %w", )
		}
		.FolderID = 
	}
	return nil
}

// GetFolderID returns value of FolderID field.
func ( *InputDialogPeerFolder) () ( int) {
	if  == nil {
		return
	}
	return .FolderID
}

// InputDialogPeerClassName is schema name of InputDialogPeerClass.
const InputDialogPeerClassName = "InputDialogPeer"

// InputDialogPeerClass represents InputDialogPeer generic type.
//
// See https://core.telegram.org/type/InputDialogPeer for reference.
//
// Example:
//
//	g, err := tg.DecodeInputDialogPeer(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputDialogPeer: // inputDialogPeer#fcaafeb7
//	case *tg.InputDialogPeerFolder: // inputDialogPeerFolder#64600527
//	default: panic(v)
//	}
type InputDialogPeerClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputDialogPeerClass

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

// DecodeInputDialogPeer implements binary de-serialization for InputDialogPeerClass.
func ( *bin.Buffer) (InputDialogPeerClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputDialogPeerTypeID:
		// Decoding inputDialogPeer#fcaafeb7.
		 := InputDialogPeer{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputDialogPeerClass: %w", )
		}
		return &, nil
	case InputDialogPeerFolderTypeID:
		// Decoding inputDialogPeerFolder#64600527.
		 := InputDialogPeerFolder{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputDialogPeerClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputDialogPeerClass: %w", bin.NewUnexpectedID())
	}
}

// InputDialogPeer boxes the InputDialogPeerClass providing a helper.
type InputDialogPeerBox struct {
	InputDialogPeer InputDialogPeerClass
}

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

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