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

// InputFile represents TL type `inputFile#f52ff27f`.
// Defines a file saved in parts using the method upload.saveFilePart¹.
//
// Links:
//  1. https://core.telegram.org/method/upload.saveFilePart
//
// See https://core.telegram.org/constructor/inputFile for reference.
type InputFile struct {
	// Random file identifier created by the client
	ID int64
	// Number of parts saved
	Parts int
	// Full name of the file
	Name string
	// In case the file's md5-hash¹ was passed, contents of the file will be checked prior
	// to use
	//
	// Links:
	//  1) https://en.wikipedia.org/wiki/MD5#MD5_hashes
	MD5Checksum string
}

// InputFileTypeID is TL type id of InputFile.
const InputFileTypeID = 0xf52ff27f

// construct implements constructor of InputFileClass.
func ( InputFile) () InputFileClass { return & }

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

	_ InputFileClass = &InputFile{}
)

func ( *InputFile) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Parts == 0) {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.MD5Checksum == "") {
		return false
	}

	return true
}

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

// FillFrom fills InputFile from given interface.
func ( *InputFile) ( interface {
	() ( int64)
	() ( int)
	() ( string)
	() ( string)
}) {
	.ID = .()
	.Parts = .()
	.Name = .()
	.MD5Checksum = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputFile) () tdp.Type {
	 := tdp.Type{
		Name: "inputFile",
		ID:   InputFileTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Parts",
			SchemaName: "parts",
		},
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "MD5Checksum",
			SchemaName: "md5_checksum",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputFile#f52ff27f as nil")
	}
	.PutID(InputFileTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputFile#f52ff27f as nil")
	}
	.PutLong(.ID)
	.PutInt(.Parts)
	.PutString(.Name)
	.PutString(.MD5Checksum)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputFile#f52ff27f to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputFile#f52ff27f: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputFile#f52ff27f: field parts: %w", )
		}
		.Parts = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputFile#f52ff27f: field name: %w", )
		}
		.Name = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputFile#f52ff27f: field md5_checksum: %w", )
		}
		.MD5Checksum = 
	}
	return nil
}

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

// GetParts returns value of Parts field.
func ( *InputFile) () ( int) {
	if  == nil {
		return
	}
	return .Parts
}

// GetName returns value of Name field.
func ( *InputFile) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// GetMD5Checksum returns value of MD5Checksum field.
func ( *InputFile) () ( string) {
	if  == nil {
		return
	}
	return .MD5Checksum
}

// InputFileBig represents TL type `inputFileBig#fa4f0bb5`.
// Assigns a big file (over 10 MB in size), saved in part using the method upload
// saveBigFilePart¹.
//
// Links:
//  1. https://core.telegram.org/method/upload.saveBigFilePart
//
// See https://core.telegram.org/constructor/inputFileBig for reference.
type InputFileBig struct {
	// Random file id, created by the client
	ID int64
	// Number of parts saved
	Parts int
	// Full file name
	Name string
}

// InputFileBigTypeID is TL type id of InputFileBig.
const InputFileBigTypeID = 0xfa4f0bb5

// construct implements constructor of InputFileClass.
func ( InputFileBig) () InputFileClass { return & }

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

	_ InputFileClass = &InputFileBig{}
)

func ( *InputFileBig) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Parts == 0) {
		return false
	}
	if !(.Name == "") {
		return false
	}

	return true
}

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

// FillFrom fills InputFileBig from given interface.
func ( *InputFileBig) ( interface {
	() ( int64)
	() ( int)
	() ( string)
}) {
	.ID = .()
	.Parts = .()
	.Name = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputFileBig) () tdp.Type {
	 := tdp.Type{
		Name: "inputFileBig",
		ID:   InputFileBigTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Parts",
			SchemaName: "parts",
		},
		{
			Name:       "Name",
			SchemaName: "name",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputFileBig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputFileBig#fa4f0bb5 as nil")
	}
	.PutID(InputFileBigTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputFileBig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputFileBig#fa4f0bb5 as nil")
	}
	.PutLong(.ID)
	.PutInt(.Parts)
	.PutString(.Name)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputFileBig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputFileBig#fa4f0bb5 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputFileBig#fa4f0bb5: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputFileBig#fa4f0bb5: field parts: %w", )
		}
		.Parts = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputFileBig#fa4f0bb5: field name: %w", )
		}
		.Name = 
	}
	return nil
}

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

// GetParts returns value of Parts field.
func ( *InputFileBig) () ( int) {
	if  == nil {
		return
	}
	return .Parts
}

// GetName returns value of Name field.
func ( *InputFileBig) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// InputFileClassName is schema name of InputFileClass.
const InputFileClassName = "InputFile"

// InputFileClass represents InputFile generic type.
//
// See https://core.telegram.org/type/InputFile for reference.
//
// Example:
//
//	g, err := tg.DecodeInputFile(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputFile: // inputFile#f52ff27f
//	case *tg.InputFileBig: // inputFileBig#fa4f0bb5
//	default: panic(v)
//	}
type InputFileClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputFileClass

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

	// Random file identifier created by the client
	GetID() (value int64)

	// Number of parts saved
	GetParts() (value int)

	// Full name of the file
	GetName() (value string)
}

// DecodeInputFile implements binary de-serialization for InputFileClass.
func ( *bin.Buffer) (InputFileClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputFileTypeID:
		// Decoding inputFile#f52ff27f.
		 := InputFile{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputFileClass: %w", )
		}
		return &, nil
	case InputFileBigTypeID:
		// Decoding inputFileBig#fa4f0bb5.
		 := InputFileBig{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputFileClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputFileClass: %w", bin.NewUnexpectedID())
	}
}

// InputFile boxes the InputFileClass providing a helper.
type InputFileBox struct {
	InputFile InputFileClass
}

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

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