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

// EncryptedFileEmpty represents TL type `encryptedFileEmpty#c21f497e`.
// Empty constructor, non-existing file.
//
// See https://core.telegram.org/constructor/encryptedFileEmpty for reference.
type EncryptedFileEmpty struct {
}

// EncryptedFileEmptyTypeID is TL type id of EncryptedFileEmpty.
const EncryptedFileEmptyTypeID = 0xc21f497e

// construct implements constructor of EncryptedFileClass.
func ( EncryptedFileEmpty) () EncryptedFileClass { return & }

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

	_ EncryptedFileClass = &EncryptedFileEmpty{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *EncryptedFileEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedFileEmpty#c21f497e as nil")
	}
	.PutID(EncryptedFileEmptyTypeID)
	return .EncodeBare()
}

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

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

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

// EncryptedFile represents TL type `encryptedFile#a8008cd8`.
// Encrypted file.
//
// See https://core.telegram.org/constructor/encryptedFile for reference.
type EncryptedFile struct {
	// File ID
	ID int64
	// Checking sum depending on user ID
	AccessHash int64
	// File size in bytes
	Size int64
	// Number of data center
	DCID int
	// 32-bit fingerprint of key used for file encryption
	KeyFingerprint int
}

// EncryptedFileTypeID is TL type id of EncryptedFile.
const EncryptedFileTypeID = 0xa8008cd8

// construct implements constructor of EncryptedFileClass.
func ( EncryptedFile) () EncryptedFileClass { return & }

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

	_ EncryptedFileClass = &EncryptedFile{}
)

func ( *EncryptedFile) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Size == 0) {
		return false
	}
	if !(.DCID == 0) {
		return false
	}
	if !(.KeyFingerprint == 0) {
		return false
	}

	return true
}

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

// FillFrom fills EncryptedFile from given interface.
func ( *EncryptedFile) ( interface {
	() ( int64)
	() ( int64)
	() ( int64)
	() ( int)
	() ( int)
}) {
	.ID = .()
	.AccessHash = .()
	.Size = .()
	.DCID = .()
	.KeyFingerprint = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EncryptedFile) () tdp.Type {
	 := tdp.Type{
		Name: "encryptedFile",
		ID:   EncryptedFileTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Size",
			SchemaName: "size",
		},
		{
			Name:       "DCID",
			SchemaName: "dc_id",
		},
		{
			Name:       "KeyFingerprint",
			SchemaName: "key_fingerprint",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EncryptedFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedFile#a8008cd8 as nil")
	}
	.PutID(EncryptedFileTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EncryptedFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedFile#a8008cd8 as nil")
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutLong(.Size)
	.PutInt(.DCID)
	.PutInt(.KeyFingerprint)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EncryptedFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode encryptedFile#a8008cd8 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedFile#a8008cd8: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedFile#a8008cd8: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedFile#a8008cd8: field size: %w", )
		}
		.Size = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedFile#a8008cd8: field dc_id: %w", )
		}
		.DCID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedFile#a8008cd8: field key_fingerprint: %w", )
		}
		.KeyFingerprint = 
	}
	return nil
}

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

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

// GetSize returns value of Size field.
func ( *EncryptedFile) () ( int64) {
	if  == nil {
		return
	}
	return .Size
}

// GetDCID returns value of DCID field.
func ( *EncryptedFile) () ( int) {
	if  == nil {
		return
	}
	return .DCID
}

// GetKeyFingerprint returns value of KeyFingerprint field.
func ( *EncryptedFile) () ( int) {
	if  == nil {
		return
	}
	return .KeyFingerprint
}

// EncryptedFileClassName is schema name of EncryptedFileClass.
const EncryptedFileClassName = "EncryptedFile"

// EncryptedFileClass represents EncryptedFile generic type.
//
// See https://core.telegram.org/type/EncryptedFile for reference.
//
// Example:
//
//	g, err := tg.DecodeEncryptedFile(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.EncryptedFileEmpty: // encryptedFileEmpty#c21f497e
//	case *tg.EncryptedFile: // encryptedFile#a8008cd8
//	default: panic(v)
//	}
type EncryptedFileClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() EncryptedFileClass

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

// AsInputEncryptedFileLocation tries to map EncryptedFile to InputEncryptedFileLocation.
func ( *EncryptedFile) () *InputEncryptedFileLocation {
	 := new(InputEncryptedFileLocation)
	.ID = .GetID()
	.AccessHash = .GetAccessHash()

	return 
}

// AsInput tries to map EncryptedFile to InputEncryptedFile.
func ( *EncryptedFile) () *InputEncryptedFile {
	 := new(InputEncryptedFile)
	.ID = .GetID()
	.AccessHash = .GetAccessHash()

	return 
}

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

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

// DecodeEncryptedFile implements binary de-serialization for EncryptedFileClass.
func ( *bin.Buffer) (EncryptedFileClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case EncryptedFileEmptyTypeID:
		// Decoding encryptedFileEmpty#c21f497e.
		 := EncryptedFileEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EncryptedFileClass: %w", )
		}
		return &, nil
	case EncryptedFileTypeID:
		// Decoding encryptedFile#a8008cd8.
		 := EncryptedFile{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EncryptedFileClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode EncryptedFileClass: %w", bin.NewUnexpectedID())
	}
}

// EncryptedFile boxes the EncryptedFileClass providing a helper.
type EncryptedFileBox struct {
	EncryptedFile EncryptedFileClass
}

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

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