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

// InputSecureFileUploaded represents TL type `inputSecureFileUploaded#3334b0f0`.
// Uploaded secure file, for more info see the passport docs »¹
//
// Links:
//  1. https://core.telegram.org/passport/encryption#inputsecurefile
//
// See https://core.telegram.org/constructor/inputSecureFileUploaded for reference.
type InputSecureFileUploaded struct {
	// Secure file ID
	ID int64
	// Secure file part count
	Parts int
	// MD5 hash of encrypted uploaded file, to be checked server-side
	MD5Checksum string
	// File hash
	FileHash []byte
	// Secret
	Secret []byte
}

// InputSecureFileUploadedTypeID is TL type id of InputSecureFileUploaded.
const InputSecureFileUploadedTypeID = 0x3334b0f0

// construct implements constructor of InputSecureFileClass.
func ( InputSecureFileUploaded) () InputSecureFileClass { return & }

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

	_ InputSecureFileClass = &InputSecureFileUploaded{}
)

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

	return true
}

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

// FillFrom fills InputSecureFileUploaded from given interface.
func ( *InputSecureFileUploaded) ( interface {
	() ( int64)
	() ( int)
	() ( string)
	() ( []byte)
	() ( []byte)
}) {
	.ID = .()
	.Parts = .()
	.MD5Checksum = .()
	.FileHash = .()
	.Secret = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputSecureFileUploaded) () tdp.Type {
	 := tdp.Type{
		Name: "inputSecureFileUploaded",
		ID:   InputSecureFileUploadedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Parts",
			SchemaName: "parts",
		},
		{
			Name:       "MD5Checksum",
			SchemaName: "md5_checksum",
		},
		{
			Name:       "FileHash",
			SchemaName: "file_hash",
		},
		{
			Name:       "Secret",
			SchemaName: "secret",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputSecureFileUploaded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputSecureFileUploaded#3334b0f0 as nil")
	}
	.PutID(InputSecureFileUploadedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputSecureFileUploaded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputSecureFileUploaded#3334b0f0 as nil")
	}
	.PutLong(.ID)
	.PutInt(.Parts)
	.PutString(.MD5Checksum)
	.PutBytes(.FileHash)
	.PutBytes(.Secret)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputSecureFileUploaded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputSecureFileUploaded#3334b0f0 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputSecureFileUploaded#3334b0f0: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputSecureFileUploaded#3334b0f0: field parts: %w", )
		}
		.Parts = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputSecureFileUploaded#3334b0f0: field md5_checksum: %w", )
		}
		.MD5Checksum = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputSecureFileUploaded#3334b0f0: field file_hash: %w", )
		}
		.FileHash = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputSecureFileUploaded#3334b0f0: field secret: %w", )
		}
		.Secret = 
	}
	return nil
}

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

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

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

// GetFileHash returns value of FileHash field.
func ( *InputSecureFileUploaded) () ( []byte) {
	if  == nil {
		return
	}
	return .FileHash
}

// GetSecret returns value of Secret field.
func ( *InputSecureFileUploaded) () ( []byte) {
	if  == nil {
		return
	}
	return .Secret
}

// InputSecureFile represents TL type `inputSecureFile#5367e5be`.
// Pre-uploaded passport¹ file, for more info see the passport docs »²
//
// Links:
//  1. https://core.telegram.org/passport
//  2. https://core.telegram.org/passport/encryption#inputsecurefile
//
// See https://core.telegram.org/constructor/inputSecureFile for reference.
type InputSecureFile struct {
	// Secure file ID
	ID int64
	// Secure file access hash
	AccessHash int64
}

// InputSecureFileTypeID is TL type id of InputSecureFile.
const InputSecureFileTypeID = 0x5367e5be

// construct implements constructor of InputSecureFileClass.
func ( InputSecureFile) () InputSecureFileClass { return & }

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

	_ InputSecureFileClass = &InputSecureFile{}
)

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputSecureFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputSecureFile#5367e5be as nil")
	}
	.PutID(InputSecureFileTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputSecureFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputSecureFile#5367e5be as nil")
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputSecureFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputSecureFile#5367e5be to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputSecureFile#5367e5be: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputSecureFile#5367e5be: field access_hash: %w", )
		}
		.AccessHash = 
	}
	return nil
}

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

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

// InputSecureFileClassName is schema name of InputSecureFileClass.
const InputSecureFileClassName = "InputSecureFile"

// InputSecureFileClass represents InputSecureFile generic type.
//
// See https://core.telegram.org/type/InputSecureFile for reference.
//
// Example:
//
//	g, err := tg.DecodeInputSecureFile(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputSecureFileUploaded: // inputSecureFileUploaded#3334b0f0
//	case *tg.InputSecureFile: // inputSecureFile#5367e5be
//	default: panic(v)
//	}
type InputSecureFileClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputSecureFileClass

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

	// Secure file ID
	GetID() (value int64)
}

// AsInputSecureFileLocation tries to map InputSecureFile to InputSecureFileLocation.
func ( *InputSecureFile) () *InputSecureFileLocation {
	 := new(InputSecureFileLocation)
	.ID = .GetID()
	.AccessHash = .GetAccessHash()

	return 
}

// DecodeInputSecureFile implements binary de-serialization for InputSecureFileClass.
func ( *bin.Buffer) (InputSecureFileClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputSecureFileUploadedTypeID:
		// Decoding inputSecureFileUploaded#3334b0f0.
		 := InputSecureFileUploaded{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputSecureFileClass: %w", )
		}
		return &, nil
	case InputSecureFileTypeID:
		// Decoding inputSecureFile#5367e5be.
		 := InputSecureFile{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputSecureFileClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputSecureFileClass: %w", bin.NewUnexpectedID())
	}
}

// InputSecureFile boxes the InputSecureFileClass providing a helper.
type InputSecureFileBox struct {
	InputSecureFile InputSecureFileClass
}

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

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