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

// PaymentsCurrencyRates represents TL type `payments.currencyRates#bbcce4c2`.
//
// See https://core.telegram.org/constructor/payments.currencyRates for reference.
type PaymentsCurrencyRates struct {
	// Rates field of PaymentsCurrencyRates.
	Rates []CurrencyRate
}

// PaymentsCurrencyRatesTypeID is TL type id of PaymentsCurrencyRates.
const PaymentsCurrencyRatesTypeID = 0xbbcce4c2

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

func ( *PaymentsCurrencyRates) () bool {
	if  == nil {
		return true
	}
	if !(.Rates == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsCurrencyRates from given interface.
func ( *PaymentsCurrencyRates) ( interface {
	() ( []CurrencyRate)
}) {
	.Rates = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsCurrencyRates) () string {
	return "payments.currencyRates"
}

// TypeInfo returns info about TL type.
func ( *PaymentsCurrencyRates) () tdp.Type {
	 := tdp.Type{
		Name: "payments.currencyRates",
		ID:   PaymentsCurrencyRatesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Rates",
			SchemaName: "rates",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsCurrencyRates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.currencyRates#bbcce4c2 as nil")
	}
	.PutID(PaymentsCurrencyRatesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsCurrencyRates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.currencyRates#bbcce4c2 as nil")
	}
	.PutVectorHeader(len(.Rates))
	for ,  := range .Rates {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.currencyRates#bbcce4c2: field rates element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsCurrencyRates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.currencyRates#bbcce4c2 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.currencyRates#bbcce4c2: field rates: %w", )
		}

		if  > 0 {
			.Rates = make([]CurrencyRate, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  CurrencyRate
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode payments.currencyRates#bbcce4c2: field rates: %w", )
			}
			.Rates = append(.Rates, )
		}
	}
	return nil
}

// GetRates returns value of Rates field.
func ( *PaymentsCurrencyRates) () ( []CurrencyRate) {
	if  == nil {
		return
	}
	return .Rates
}