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

// CDNConfig represents TL type `cdnConfig#5725e40a`.
// Configuration for CDN¹ file downloads.
//
// Links:
//  1. https://core.telegram.org/cdn
//
// See https://core.telegram.org/constructor/cdnConfig for reference.
type CDNConfig struct {
	// Vector of public keys to use only during handshakes to CDN¹ DCs.
	//
	// Links:
	//  1) https://core.telegram.org/cdn
	PublicKeys []CDNPublicKey
}

// CDNConfigTypeID is TL type id of CDNConfig.
const CDNConfigTypeID = 0x5725e40a

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

func ( *CDNConfig) () bool {
	if  == nil {
		return true
	}
	if !(.PublicKeys == nil) {
		return false
	}

	return true
}

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

// FillFrom fills CDNConfig from given interface.
func ( *CDNConfig) ( interface {
	() ( []CDNPublicKey)
}) {
	.PublicKeys = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *CDNConfig) () tdp.Type {
	 := tdp.Type{
		Name: "cdnConfig",
		ID:   CDNConfigTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PublicKeys",
			SchemaName: "public_keys",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *CDNConfig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode cdnConfig#5725e40a as nil")
	}
	.PutID(CDNConfigTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *CDNConfig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode cdnConfig#5725e40a as nil")
	}
	.PutVectorHeader(len(.PublicKeys))
	for ,  := range .PublicKeys {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode cdnConfig#5725e40a: field public_keys element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *CDNConfig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode cdnConfig#5725e40a to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode cdnConfig#5725e40a: field public_keys: %w", )
		}

		if  > 0 {
			.PublicKeys = make([]CDNPublicKey, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  CDNPublicKey
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode cdnConfig#5725e40a: field public_keys: %w", )
			}
			.PublicKeys = append(.PublicKeys, )
		}
	}
	return nil
}

// GetPublicKeys returns value of PublicKeys field.
func ( *CDNConfig) () ( []CDNPublicKey) {
	if  == nil {
		return
	}
	return .PublicKeys
}