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

// CurrencyRate represents TL type `currencyRate#30d9743c`.
//
// See https://core.telegram.org/constructor/currencyRate for reference.
type CurrencyRate struct {
	// Currency field of CurrencyRate.
	Currency string
	// Rate field of CurrencyRate.
	Rate float64
}

// CurrencyRateTypeID is TL type id of CurrencyRate.
const CurrencyRateTypeID = 0x30d9743c

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

func ( *CurrencyRate) () bool {
	if  == nil {
		return true
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Rate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills CurrencyRate from given interface.
func ( *CurrencyRate) ( interface {
	() ( string)
	() ( float64)
}) {
	.Currency = .()
	.Rate = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *CurrencyRate) () tdp.Type {
	 := tdp.Type{
		Name: "currencyRate",
		ID:   CurrencyRateTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Rate",
			SchemaName: "rate",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *CurrencyRate) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode currencyRate#30d9743c as nil")
	}
	.PutID(CurrencyRateTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *CurrencyRate) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode currencyRate#30d9743c as nil")
	}
	.PutString(.Currency)
	.PutDouble(.Rate)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *CurrencyRate) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode currencyRate#30d9743c to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode currencyRate#30d9743c: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode currencyRate#30d9743c: field rate: %w", )
		}
		.Rate = 
	}
	return nil
}

// GetCurrency returns value of Currency field.
func ( *CurrencyRate) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

// GetRate returns value of Rate field.
func ( *CurrencyRate) () ( float64) {
	if  == nil {
		return
	}
	return .Rate
}