// Code generated by gotdgen, DO NOT EDIT.

package mt

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

// DhGenOk represents TL type `dh_gen_ok#3bcbf734`.
type DhGenOk struct {
	// Nonce field of DhGenOk.
	Nonce bin.Int128
	// ServerNonce field of DhGenOk.
	ServerNonce bin.Int128
	// NewNonceHash1 field of DhGenOk.
	NewNonceHash1 bin.Int128
}

// DhGenOkTypeID is TL type id of DhGenOk.
const DhGenOkTypeID = 0x3bcbf734

// construct implements constructor of SetClientDHParamsAnswerClass.
func ( DhGenOk) () SetClientDHParamsAnswerClass { return & }

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

	_ SetClientDHParamsAnswerClass = &DhGenOk{}
)

func ( *DhGenOk) () bool {
	if  == nil {
		return true
	}
	if !(.Nonce == bin.Int128{}) {
		return false
	}
	if !(.ServerNonce == bin.Int128{}) {
		return false
	}
	if !(.NewNonceHash1 == bin.Int128{}) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *DhGenOk) () tdp.Type {
	 := tdp.Type{
		Name: "dh_gen_ok",
		ID:   DhGenOkTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Nonce",
			SchemaName: "nonce",
		},
		{
			Name:       "ServerNonce",
			SchemaName: "server_nonce",
		},
		{
			Name:       "NewNonceHash1",
			SchemaName: "new_nonce_hash1",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DhGenOk) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dh_gen_ok#3bcbf734 as nil")
	}
	.PutID(DhGenOkTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DhGenOk) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dh_gen_ok#3bcbf734 as nil")
	}
	.PutInt128(.Nonce)
	.PutInt128(.ServerNonce)
	.PutInt128(.NewNonceHash1)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DhGenOk) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dh_gen_ok#3bcbf734 to nil")
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_ok#3bcbf734: field nonce: %w", )
		}
		.Nonce = 
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_ok#3bcbf734: field server_nonce: %w", )
		}
		.ServerNonce = 
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_ok#3bcbf734: field new_nonce_hash1: %w", )
		}
		.NewNonceHash1 = 
	}
	return nil
}

// GetNonce returns value of Nonce field.
func ( *DhGenOk) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .Nonce
}

// GetServerNonce returns value of ServerNonce field.
func ( *DhGenOk) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .ServerNonce
}

// GetNewNonceHash1 returns value of NewNonceHash1 field.
func ( *DhGenOk) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .NewNonceHash1
}

// DhGenRetry represents TL type `dh_gen_retry#46dc1fb9`.
type DhGenRetry struct {
	// Nonce field of DhGenRetry.
	Nonce bin.Int128
	// ServerNonce field of DhGenRetry.
	ServerNonce bin.Int128
	// NewNonceHash2 field of DhGenRetry.
	NewNonceHash2 bin.Int128
}

// DhGenRetryTypeID is TL type id of DhGenRetry.
const DhGenRetryTypeID = 0x46dc1fb9

// construct implements constructor of SetClientDHParamsAnswerClass.
func ( DhGenRetry) () SetClientDHParamsAnswerClass { return & }

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

	_ SetClientDHParamsAnswerClass = &DhGenRetry{}
)

func ( *DhGenRetry) () bool {
	if  == nil {
		return true
	}
	if !(.Nonce == bin.Int128{}) {
		return false
	}
	if !(.ServerNonce == bin.Int128{}) {
		return false
	}
	if !(.NewNonceHash2 == bin.Int128{}) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *DhGenRetry) () tdp.Type {
	 := tdp.Type{
		Name: "dh_gen_retry",
		ID:   DhGenRetryTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Nonce",
			SchemaName: "nonce",
		},
		{
			Name:       "ServerNonce",
			SchemaName: "server_nonce",
		},
		{
			Name:       "NewNonceHash2",
			SchemaName: "new_nonce_hash2",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DhGenRetry) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dh_gen_retry#46dc1fb9 as nil")
	}
	.PutID(DhGenRetryTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DhGenRetry) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dh_gen_retry#46dc1fb9 as nil")
	}
	.PutInt128(.Nonce)
	.PutInt128(.ServerNonce)
	.PutInt128(.NewNonceHash2)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DhGenRetry) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dh_gen_retry#46dc1fb9 to nil")
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_retry#46dc1fb9: field nonce: %w", )
		}
		.Nonce = 
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_retry#46dc1fb9: field server_nonce: %w", )
		}
		.ServerNonce = 
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_retry#46dc1fb9: field new_nonce_hash2: %w", )
		}
		.NewNonceHash2 = 
	}
	return nil
}

// GetNonce returns value of Nonce field.
func ( *DhGenRetry) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .Nonce
}

// GetServerNonce returns value of ServerNonce field.
func ( *DhGenRetry) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .ServerNonce
}

// GetNewNonceHash2 returns value of NewNonceHash2 field.
func ( *DhGenRetry) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .NewNonceHash2
}

// DhGenFail represents TL type `dh_gen_fail#a69dae02`.
type DhGenFail struct {
	// Nonce field of DhGenFail.
	Nonce bin.Int128
	// ServerNonce field of DhGenFail.
	ServerNonce bin.Int128
	// NewNonceHash3 field of DhGenFail.
	NewNonceHash3 bin.Int128
}

// DhGenFailTypeID is TL type id of DhGenFail.
const DhGenFailTypeID = 0xa69dae02

// construct implements constructor of SetClientDHParamsAnswerClass.
func ( DhGenFail) () SetClientDHParamsAnswerClass { return & }

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

	_ SetClientDHParamsAnswerClass = &DhGenFail{}
)

func ( *DhGenFail) () bool {
	if  == nil {
		return true
	}
	if !(.Nonce == bin.Int128{}) {
		return false
	}
	if !(.ServerNonce == bin.Int128{}) {
		return false
	}
	if !(.NewNonceHash3 == bin.Int128{}) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *DhGenFail) () tdp.Type {
	 := tdp.Type{
		Name: "dh_gen_fail",
		ID:   DhGenFailTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Nonce",
			SchemaName: "nonce",
		},
		{
			Name:       "ServerNonce",
			SchemaName: "server_nonce",
		},
		{
			Name:       "NewNonceHash3",
			SchemaName: "new_nonce_hash3",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DhGenFail) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dh_gen_fail#a69dae02 as nil")
	}
	.PutID(DhGenFailTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DhGenFail) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dh_gen_fail#a69dae02 as nil")
	}
	.PutInt128(.Nonce)
	.PutInt128(.ServerNonce)
	.PutInt128(.NewNonceHash3)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DhGenFail) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dh_gen_fail#a69dae02 to nil")
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_fail#a69dae02: field nonce: %w", )
		}
		.Nonce = 
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_fail#a69dae02: field server_nonce: %w", )
		}
		.ServerNonce = 
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode dh_gen_fail#a69dae02: field new_nonce_hash3: %w", )
		}
		.NewNonceHash3 = 
	}
	return nil
}

// GetNonce returns value of Nonce field.
func ( *DhGenFail) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .Nonce
}

// GetServerNonce returns value of ServerNonce field.
func ( *DhGenFail) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .ServerNonce
}

// GetNewNonceHash3 returns value of NewNonceHash3 field.
func ( *DhGenFail) () ( bin.Int128) {
	if  == nil {
		return
	}
	return .NewNonceHash3
}

// SetClientDHParamsAnswerClassName is schema name of SetClientDHParamsAnswerClass.
const SetClientDHParamsAnswerClassName = "Set_client_DH_params_answer"

// SetClientDHParamsAnswerClass represents Set_client_DH_params_answer generic type.
//
// Example:
//
//	g, err := mt.DecodeSetClientDHParamsAnswer(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *mt.DhGenOk: // dh_gen_ok#3bcbf734
//	case *mt.DhGenRetry: // dh_gen_retry#46dc1fb9
//	case *mt.DhGenFail: // dh_gen_fail#a69dae02
//	default: panic(v)
//	}
type SetClientDHParamsAnswerClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() SetClientDHParamsAnswerClass

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

	// Nonce field of DhGenOk.
	GetNonce() (value bin.Int128)
	// ServerNonce field of DhGenOk.
	GetServerNonce() (value bin.Int128)
}

// DecodeSetClientDHParamsAnswer implements binary de-serialization for SetClientDHParamsAnswerClass.
func ( *bin.Buffer) (SetClientDHParamsAnswerClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case DhGenOkTypeID:
		// Decoding dh_gen_ok#3bcbf734.
		 := DhGenOk{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SetClientDHParamsAnswerClass: %w", )
		}
		return &, nil
	case DhGenRetryTypeID:
		// Decoding dh_gen_retry#46dc1fb9.
		 := DhGenRetry{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SetClientDHParamsAnswerClass: %w", )
		}
		return &, nil
	case DhGenFailTypeID:
		// Decoding dh_gen_fail#a69dae02.
		 := DhGenFail{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SetClientDHParamsAnswerClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode SetClientDHParamsAnswerClass: %w", bin.NewUnexpectedID())
	}
}

// SetClientDHParamsAnswer boxes the SetClientDHParamsAnswerClass providing a helper.
type SetClientDHParamsAnswerBox struct {
	Set_client_DH_params_answer SetClientDHParamsAnswerClass
}

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

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