ExchangeRateFnV2

Trait ExchangeRateFnV2 

Source
pub trait ExchangeRateFnV2 {
    // Required method
    fn relative_to_base_currency(
        &self,
        currency: &str,
        options: &ExchangeRateFnV2Options,
    ) -> Result<f64, Box<dyn Error + Send + Sync + 'static>>;
}
Expand description

An exchange rate handler.

Required Methods§

Source

fn relative_to_base_currency( &self, currency: &str, options: &ExchangeRateFnV2Options, ) -> Result<f64, Box<dyn Error + Send + Sync + 'static>>

Returns the value of a currency relative to the base currency. The base currency depends on your implementation. fend-core can work with any base currency as long as it is consistent.

If options.is_preview() returns true, implementors are encouraged to only return cached or pre-fetched results. Blocking the thread for an extended period of time is not ideal if this calculation is merely for a preview.

§Errors

This function errors out if the currency was not found or the conversion is impossible for any reason (HTTP request failed, etc.)

Implementors§