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

// CDNPublicKey represents TL type `cdnPublicKey#c982eaba`.
// Public key to use only during handshakes to CDN¹ DCs.
//
// Links:
//  1. https://core.telegram.org/cdn
//
// See https://core.telegram.org/constructor/cdnPublicKey for reference.
type CDNPublicKey struct {
	// CDN DC¹ ID
	//
	// Links:
	//  1) https://core.telegram.org/cdn
	DCID int
	// RSA public key
	PublicKey string
}

// CDNPublicKeyTypeID is TL type id of CDNPublicKey.
const CDNPublicKeyTypeID = 0xc982eaba

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

func ( *CDNPublicKey) () bool {
	if  == nil {
		return true
	}
	if !(.DCID == 0) {
		return false
	}
	if !(.PublicKey == "") {
		return false
	}

	return true
}

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

// FillFrom fills CDNPublicKey from given interface.
func ( *CDNPublicKey) ( interface {
	() ( int)
	() ( string)
}) {
	.DCID = .()
	.PublicKey = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *CDNPublicKey) () tdp.Type {
	 := tdp.Type{
		Name: "cdnPublicKey",
		ID:   CDNPublicKeyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "DCID",
			SchemaName: "dc_id",
		},
		{
			Name:       "PublicKey",
			SchemaName: "public_key",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *CDNPublicKey) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode cdnPublicKey#c982eaba as nil")
	}
	.PutID(CDNPublicKeyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *CDNPublicKey) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode cdnPublicKey#c982eaba as nil")
	}
	.PutInt(.DCID)
	.PutString(.PublicKey)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *CDNPublicKey) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode cdnPublicKey#c982eaba to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode cdnPublicKey#c982eaba: field dc_id: %w", )
		}
		.DCID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode cdnPublicKey#c982eaba: field public_key: %w", )
		}
		.PublicKey = 
	}
	return nil
}

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

// GetPublicKey returns value of PublicKey field.
func ( *CDNPublicKey) () ( string) {
	if  == nil {
		return
	}
	return .PublicKey
}