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

// SecureFileEmpty represents TL type `secureFileEmpty#64199744`.
// Empty constructor
//
// See https://core.telegram.org/constructor/secureFileEmpty for reference.
type SecureFileEmpty struct {
}

// SecureFileEmptyTypeID is TL type id of SecureFileEmpty.
const SecureFileEmptyTypeID = 0x64199744

// construct implements constructor of SecureFileClass.
func ( SecureFileEmpty) () SecureFileClass { return & }

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

	_ SecureFileClass = &SecureFileEmpty{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *SecureFileEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode secureFileEmpty#64199744 as nil")
	}
	.PutID(SecureFileEmptyTypeID)
	return .EncodeBare()
}

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

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

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

// SecureFile represents TL type `secureFile#7d09c27e`.
// Secure 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/secureFile for reference.
type SecureFile struct {
	// ID
	ID int64
	// Access hash
	AccessHash int64
	// File size
	Size int64
	// DC ID
	DCID int
	// Date of upload
	Date int
	// File hash
	FileHash []byte
	// Secret
	Secret []byte
}

// SecureFileTypeID is TL type id of SecureFile.
const SecureFileTypeID = 0x7d09c27e

// construct implements constructor of SecureFileClass.
func ( SecureFile) () SecureFileClass { return & }

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

	_ SecureFileClass = &SecureFile{}
)

func ( *SecureFile) () 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 !(.Date == 0) {
		return false
	}
	if !(.FileHash == nil) {
		return false
	}
	if !(.Secret == nil) {
		return false
	}

	return true
}

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

// FillFrom fills SecureFile from given interface.
func ( *SecureFile) ( interface {
	() ( int64)
	() ( int64)
	() ( int64)
	() ( int)
	() ( int)
	() ( []byte)
	() ( []byte)
}) {
	.ID = .()
	.AccessHash = .()
	.Size = .()
	.DCID = .()
	.Date = .()
	.FileHash = .()
	.Secret = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SecureFile) () tdp.Type {
	 := tdp.Type{
		Name: "secureFile",
		ID:   SecureFileTypeID,
	}
	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:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "FileHash",
			SchemaName: "file_hash",
		},
		{
			Name:       "Secret",
			SchemaName: "secret",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SecureFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode secureFile#7d09c27e as nil")
	}
	.PutID(SecureFileTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SecureFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode secureFile#7d09c27e as nil")
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutLong(.Size)
	.PutInt(.DCID)
	.PutInt(.Date)
	.PutBytes(.FileHash)
	.PutBytes(.Secret)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SecureFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode secureFile#7d09c27e to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode secureFile#7d09c27e: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode secureFile#7d09c27e: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode secureFile#7d09c27e: field size: %w", )
		}
		.Size = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode secureFile#7d09c27e: field dc_id: %w", )
		}
		.DCID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode secureFile#7d09c27e: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode secureFile#7d09c27e: field file_hash: %w", )
		}
		.FileHash = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode secureFile#7d09c27e: field secret: %w", )
		}
		.Secret = 
	}
	return nil
}

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

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

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

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

// GetDate returns value of Date field.
func ( *SecureFile) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

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

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

// SecureFileClassName is schema name of SecureFileClass.
const SecureFileClassName = "SecureFile"

// SecureFileClass represents SecureFile generic type.
//
// See https://core.telegram.org/type/SecureFile for reference.
//
// Example:
//
//	g, err := tg.DecodeSecureFile(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.SecureFileEmpty: // secureFileEmpty#64199744
//	case *tg.SecureFile: // secureFile#7d09c27e
//	default: panic(v)
//	}
type SecureFileClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() SecureFileClass

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

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

	return 
}

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

	return 
}

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

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

// DecodeSecureFile implements binary de-serialization for SecureFileClass.
func ( *bin.Buffer) (SecureFileClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case SecureFileEmptyTypeID:
		// Decoding secureFileEmpty#64199744.
		 := SecureFileEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SecureFileClass: %w", )
		}
		return &, nil
	case SecureFileTypeID:
		// Decoding secureFile#7d09c27e.
		 := SecureFile{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SecureFileClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode SecureFileClass: %w", bin.NewUnexpectedID())
	}
}

// SecureFile boxes the SecureFileClass providing a helper.
type SecureFileBox struct {
	SecureFile SecureFileClass
}

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

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