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

// ResPQ represents TL type `resPQ#5162463`.
type ResPQ struct {
	// Nonce field of ResPQ.
	Nonce bin.Int128
	// ServerNonce field of ResPQ.
	ServerNonce bin.Int128
	// Pq field of ResPQ.
	Pq []byte
	// ServerPublicKeyFingerprints field of ResPQ.
	ServerPublicKeyFingerprints []int64
}

// ResPQTypeID is TL type id of ResPQ.
const ResPQTypeID = 0x5162463

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

func ( *ResPQ) () bool {
	if  == nil {
		return true
	}
	if !(.Nonce == bin.Int128{}) {
		return false
	}
	if !(.ServerNonce == bin.Int128{}) {
		return false
	}
	if !(.Pq == nil) {
		return false
	}
	if !(.ServerPublicKeyFingerprints == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *ResPQ) () tdp.Type {
	 := tdp.Type{
		Name: "resPQ",
		ID:   ResPQTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Nonce",
			SchemaName: "nonce",
		},
		{
			Name:       "ServerNonce",
			SchemaName: "server_nonce",
		},
		{
			Name:       "Pq",
			SchemaName: "pq",
		},
		{
			Name:       "ServerPublicKeyFingerprints",
			SchemaName: "server_public_key_fingerprints",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ResPQ) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode resPQ#5162463 as nil")
	}
	.PutID(ResPQTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ResPQ) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode resPQ#5162463 as nil")
	}
	.PutInt128(.Nonce)
	.PutInt128(.ServerNonce)
	.PutBytes(.Pq)
	.PutVectorHeader(len(.ServerPublicKeyFingerprints))
	for ,  := range .ServerPublicKeyFingerprints {
		.PutLong()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ResPQ) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode resPQ#5162463 to nil")
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode resPQ#5162463: field nonce: %w", )
		}
		.Nonce = 
	}
	{
		,  := .Int128()
		if  != nil {
			return fmt.Errorf("unable to decode resPQ#5162463: field server_nonce: %w", )
		}
		.ServerNonce = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode resPQ#5162463: field pq: %w", )
		}
		.Pq = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode resPQ#5162463: field server_public_key_fingerprints: %w", )
		}

		if  > 0 {
			.ServerPublicKeyFingerprints = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode resPQ#5162463: field server_public_key_fingerprints: %w", )
			}
			.ServerPublicKeyFingerprints = append(.ServerPublicKeyFingerprints, )
		}
	}
	return nil
}

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

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

// GetPq returns value of Pq field.
func ( *ResPQ) () ( []byte) {
	if  == nil {
		return
	}
	return .Pq
}

// GetServerPublicKeyFingerprints returns value of ServerPublicKeyFingerprints field.
func ( *ResPQ) () ( []int64) {
	if  == nil {
		return
	}
	return .ServerPublicKeyFingerprints
}