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

// InputDocumentEmpty represents TL type `inputDocumentEmpty#72f0eaae`.
// Empty constructor.
//
// See https://core.telegram.org/constructor/inputDocumentEmpty for reference.
type InputDocumentEmpty struct {
}

// InputDocumentEmptyTypeID is TL type id of InputDocumentEmpty.
const InputDocumentEmptyTypeID = 0x72f0eaae

// construct implements constructor of InputDocumentClass.
func ( InputDocumentEmpty) () InputDocumentClass { return & }

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

	_ InputDocumentClass = &InputDocumentEmpty{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputDocumentEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputDocumentEmpty#72f0eaae as nil")
	}
	.PutID(InputDocumentEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputDocumentEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputDocumentEmpty#72f0eaae as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputDocumentEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputDocumentEmpty#72f0eaae to nil")
	}
	return nil
}

// InputDocument represents TL type `inputDocument#1abfb575`.
// Defines a document for subsequent interaction.
//
// See https://core.telegram.org/constructor/inputDocument for reference.
type InputDocument struct {
	// Document ID
	ID int64
	// access_hash parameter from the document¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/constructor/document
	AccessHash int64
	// File reference¹
	//
	// Links:
	//  1) https://core.telegram.org/api/file_reference
	FileReference []byte
}

// InputDocumentTypeID is TL type id of InputDocument.
const InputDocumentTypeID = 0x1abfb575

// construct implements constructor of InputDocumentClass.
func ( InputDocument) () InputDocumentClass { return & }

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

	_ InputDocumentClass = &InputDocument{}
)

func ( *InputDocument) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.FileReference == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputDocument from given interface.
func ( *InputDocument) ( interface {
	() ( int64)
	() ( int64)
	() ( []byte)
}) {
	.ID = .()
	.AccessHash = .()
	.FileReference = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputDocument) () tdp.Type {
	 := tdp.Type{
		Name: "inputDocument",
		ID:   InputDocumentTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "FileReference",
			SchemaName: "file_reference",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputDocument) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputDocument#1abfb575 as nil")
	}
	.PutID(InputDocumentTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputDocument) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputDocument#1abfb575 as nil")
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutBytes(.FileReference)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputDocument) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputDocument#1abfb575 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputDocument#1abfb575: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputDocument#1abfb575: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputDocument#1abfb575: field file_reference: %w", )
		}
		.FileReference = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *InputDocument) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

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

// GetFileReference returns value of FileReference field.
func ( *InputDocument) () ( []byte) {
	if  == nil {
		return
	}
	return .FileReference
}

// InputDocumentClassName is schema name of InputDocumentClass.
const InputDocumentClassName = "InputDocument"

// InputDocumentClass represents InputDocument generic type.
//
// See https://core.telegram.org/type/InputDocument for reference.
//
// Example:
//
//	g, err := tg.DecodeInputDocument(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputDocumentEmpty: // inputDocumentEmpty#72f0eaae
//	case *tg.InputDocument: // inputDocument#1abfb575
//	default: panic(v)
//	}
type InputDocumentClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputDocumentClass

	// 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 InputDocumentClass to InputDocument.
	AsNotEmpty() (*InputDocument, bool)
}

// AsInputDocumentFileLocation tries to map InputDocument to InputDocumentFileLocation.
func ( *InputDocument) () *InputDocumentFileLocation {
	 := new(InputDocumentFileLocation)
	.ID = .GetID()
	.AccessHash = .GetAccessHash()
	.FileReference = .GetFileReference()

	return 
}

// AsNotEmpty tries to map InputDocumentEmpty to InputDocument.
func ( *InputDocumentEmpty) () (*InputDocument, bool) {
	return nil, false
}

// AsNotEmpty tries to map InputDocument to InputDocument.
func ( *InputDocument) () (*InputDocument, bool) {
	return , true
}

// DecodeInputDocument implements binary de-serialization for InputDocumentClass.
func ( *bin.Buffer) (InputDocumentClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputDocumentEmptyTypeID:
		// Decoding inputDocumentEmpty#72f0eaae.
		 := InputDocumentEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputDocumentClass: %w", )
		}
		return &, nil
	case InputDocumentTypeID:
		// Decoding inputDocument#1abfb575.
		 := InputDocument{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputDocumentClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputDocumentClass: %w", bin.NewUnexpectedID())
	}
}

// InputDocument boxes the InputDocumentClass providing a helper.
type InputDocumentBox struct {
	InputDocument InputDocumentClass
}

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

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