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

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

Represents the exchange rate between Commoditys with different CommodityTypes.

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<CommodityTypeID>

The id of the base commodity type for the exchange rate

rates: BTreeMap<CommodityTypeID, Decimal>

Maps commodity type ids, to the conversion rate from that CommodityType to the base CommodityType.

Methods

impl ExchangeRate[src]

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

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

Convert the CommodityType of a Commodity to another CommodityType 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: for<'de> 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.