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

// SecurePasswordKdfAlgoUnknown represents TL type `securePasswordKdfAlgoUnknown#4a8537`.
// Unknown KDF algo (most likely the client has to be updated)
//
// See https://core.telegram.org/constructor/securePasswordKdfAlgoUnknown for reference.
type SecurePasswordKdfAlgoUnknown struct {
}

// SecurePasswordKdfAlgoUnknownTypeID is TL type id of SecurePasswordKdfAlgoUnknown.
const SecurePasswordKdfAlgoUnknownTypeID = 0x4a8537

// construct implements constructor of SecurePasswordKdfAlgoClass.
func ( SecurePasswordKdfAlgoUnknown) () SecurePasswordKdfAlgoClass { return & }

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

	_ SecurePasswordKdfAlgoClass = &SecurePasswordKdfAlgoUnknown{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *SecurePasswordKdfAlgoUnknown) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePasswordKdfAlgoUnknown#4a8537 as nil")
	}
	.PutID(SecurePasswordKdfAlgoUnknownTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SecurePasswordKdfAlgoUnknown) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePasswordKdfAlgoUnknown#4a8537 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SecurePasswordKdfAlgoUnknown) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode securePasswordKdfAlgoUnknown#4a8537 to nil")
	}
	return nil
}

// SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000 represents TL type `securePasswordKdfAlgoPBKDF2HMACSHA512iter100000#bbf2dda0`.
// PBKDF2 with SHA512 and 100000 iterations KDF algo
//
// See https://core.telegram.org/constructor/securePasswordKdfAlgoPBKDF2HMACSHA512iter100000 for reference.
type SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000 struct {
	// Salt
	Salt []byte
}

// SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000TypeID is TL type id of SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000.
const SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000TypeID = 0xbbf2dda0

// construct implements constructor of SecurePasswordKdfAlgoClass.
func ( SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) () SecurePasswordKdfAlgoClass {
	return &
}

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

	_ SecurePasswordKdfAlgoClass = &SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000{}
)

func ( *SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) () bool {
	if  == nil {
		return true
	}
	if !(.Salt == nil) {
		return false
	}

	return true
}

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

// FillFrom fills SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000 from given interface.
func ( *SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) ( interface {
	() ( []byte)
}) {
	.Salt = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) () tdp.Type {
	 := tdp.Type{
		Name: "securePasswordKdfAlgoPBKDF2HMACSHA512iter100000",
		ID:   SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000TypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Salt",
			SchemaName: "salt",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePasswordKdfAlgoPBKDF2HMACSHA512iter100000#bbf2dda0 as nil")
	}
	.PutID(SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000TypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePasswordKdfAlgoPBKDF2HMACSHA512iter100000#bbf2dda0 as nil")
	}
	.PutBytes(.Salt)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode securePasswordKdfAlgoPBKDF2HMACSHA512iter100000#bbf2dda0 to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode securePasswordKdfAlgoPBKDF2HMACSHA512iter100000#bbf2dda0: field salt: %w", )
		}
		.Salt = 
	}
	return nil
}

// GetSalt returns value of Salt field.
func ( *SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000) () ( []byte) {
	if  == nil {
		return
	}
	return .Salt
}

// SecurePasswordKdfAlgoSHA512 represents TL type `securePasswordKdfAlgoSHA512#86471d92`.
// SHA512 KDF algo
//
// See https://core.telegram.org/constructor/securePasswordKdfAlgoSHA512 for reference.
type SecurePasswordKdfAlgoSHA512 struct {
	// Salt
	Salt []byte
}

// SecurePasswordKdfAlgoSHA512TypeID is TL type id of SecurePasswordKdfAlgoSHA512.
const SecurePasswordKdfAlgoSHA512TypeID = 0x86471d92

// construct implements constructor of SecurePasswordKdfAlgoClass.
func ( SecurePasswordKdfAlgoSHA512) () SecurePasswordKdfAlgoClass { return & }

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

	_ SecurePasswordKdfAlgoClass = &SecurePasswordKdfAlgoSHA512{}
)

func ( *SecurePasswordKdfAlgoSHA512) () bool {
	if  == nil {
		return true
	}
	if !(.Salt == nil) {
		return false
	}

	return true
}

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

// FillFrom fills SecurePasswordKdfAlgoSHA512 from given interface.
func ( *SecurePasswordKdfAlgoSHA512) ( interface {
	() ( []byte)
}) {
	.Salt = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SecurePasswordKdfAlgoSHA512) () tdp.Type {
	 := tdp.Type{
		Name: "securePasswordKdfAlgoSHA512",
		ID:   SecurePasswordKdfAlgoSHA512TypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Salt",
			SchemaName: "salt",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SecurePasswordKdfAlgoSHA512) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePasswordKdfAlgoSHA512#86471d92 as nil")
	}
	.PutID(SecurePasswordKdfAlgoSHA512TypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SecurePasswordKdfAlgoSHA512) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePasswordKdfAlgoSHA512#86471d92 as nil")
	}
	.PutBytes(.Salt)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SecurePasswordKdfAlgoSHA512) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode securePasswordKdfAlgoSHA512#86471d92 to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode securePasswordKdfAlgoSHA512#86471d92: field salt: %w", )
		}
		.Salt = 
	}
	return nil
}

// GetSalt returns value of Salt field.
func ( *SecurePasswordKdfAlgoSHA512) () ( []byte) {
	if  == nil {
		return
	}
	return .Salt
}

// SecurePasswordKdfAlgoClassName is schema name of SecurePasswordKdfAlgoClass.
const SecurePasswordKdfAlgoClassName = "SecurePasswordKdfAlgo"

// SecurePasswordKdfAlgoClass represents SecurePasswordKdfAlgo generic type.
//
// See https://core.telegram.org/type/SecurePasswordKdfAlgo for reference.
//
// Example:
//
//	g, err := tg.DecodeSecurePasswordKdfAlgo(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.SecurePasswordKdfAlgoUnknown: // securePasswordKdfAlgoUnknown#4a8537
//	case *tg.SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000: // securePasswordKdfAlgoPBKDF2HMACSHA512iter100000#bbf2dda0
//	case *tg.SecurePasswordKdfAlgoSHA512: // securePasswordKdfAlgoSHA512#86471d92
//	default: panic(v)
//	}
type SecurePasswordKdfAlgoClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() SecurePasswordKdfAlgoClass

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

// DecodeSecurePasswordKdfAlgo implements binary de-serialization for SecurePasswordKdfAlgoClass.
func ( *bin.Buffer) (SecurePasswordKdfAlgoClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case SecurePasswordKdfAlgoUnknownTypeID:
		// Decoding securePasswordKdfAlgoUnknown#4a8537.
		 := SecurePasswordKdfAlgoUnknown{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SecurePasswordKdfAlgoClass: %w", )
		}
		return &, nil
	case SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000TypeID:
		// Decoding securePasswordKdfAlgoPBKDF2HMACSHA512iter100000#bbf2dda0.
		 := SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SecurePasswordKdfAlgoClass: %w", )
		}
		return &, nil
	case SecurePasswordKdfAlgoSHA512TypeID:
		// Decoding securePasswordKdfAlgoSHA512#86471d92.
		 := SecurePasswordKdfAlgoSHA512{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SecurePasswordKdfAlgoClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode SecurePasswordKdfAlgoClass: %w", bin.NewUnexpectedID())
	}
}

// SecurePasswordKdfAlgo boxes the SecurePasswordKdfAlgoClass providing a helper.
type SecurePasswordKdfAlgoBox struct {
	SecurePasswordKdfAlgo SecurePasswordKdfAlgoClass
}

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

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