[][src]Struct commodity::exchange_rate::ExchangeRate

pub struct ExchangeRate {
    pub date: Option<NaiveDate>,
    pub obtained_datetime: Option<DateTime<Utc>>,
    pub base: Option<CurrencyCode>,
    pub rates: HashMap<CurrencyCode, Decimal>,
}

Represents the exchange rate between Commoditys with different Currencys.

Fields

date: Option<NaiveDate>

The datetime that this exchange rate represents

obtained_datetime: Option<DateTime<Utc>>

The datetime that this exchange rate was obtained.

base: Option<CurrencyCode>

The base currency for the exchange rate

rates: HashMap<CurrencyCode, Decimal>

Maps currency codes, to the conversion rate from that currency to the base currency.

Methods

impl ExchangeRate[src]

pub fn get_rate(&self, currency_code: &CurrencyCode) -> Option<&Decimal>[src]

pub fn convert(
    &self,
    commodity: Commodity,
    target_currency: CurrencyCode
) -> Result<Commodity, ExchangeRateError>
[src]

Convert the currency of a Commodity from one currency to another using this ExchangeRate.

Trait Implementations

impl Clone for ExchangeRate[src]

impl Debug for ExchangeRate[src]

impl<'de> Deserialize<'de> for ExchangeRate[src]

impl Serialize for ExchangeRate[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.