pub struct ExchangeRateService { /* private fields */ }
Expand description
Enhanced service for exchange rate operations with caching
Implementations§
Source§impl ExchangeRateService
impl ExchangeRateService
Sourcepub fn new(client: CurrencyClient) -> Self
pub fn new(client: CurrencyClient) -> Self
Create a new exchange rate service with caching
Sourcepub fn with_cache_config(
client: CurrencyClient,
cache_config: CacheConfig,
) -> Self
pub fn with_cache_config( client: CurrencyClient, cache_config: CacheConfig, ) -> Self
Create a service with custom cache configuration
Sourcepub async fn get_latest_rates(
&self,
base_currency: &str,
) -> Result<ExchangeRateResponse>
pub async fn get_latest_rates( &self, base_currency: &str, ) -> Result<ExchangeRateResponse>
Fetch latest exchange rates for a base currency (with caching)
Sourcepub async fn get_historical_rates(
&self,
base_currency: &str,
date: &str,
) -> Result<HistoricalRateResponse>
pub async fn get_historical_rates( &self, base_currency: &str, date: &str, ) -> Result<HistoricalRateResponse>
Fetch historical exchange rates for a specific date
Sourcepub async fn convert_historical(
&self,
request: HistoricalConversionRequest,
) -> Result<ConversionResponse>
pub async fn convert_historical( &self, request: HistoricalConversionRequest, ) -> Result<ConversionResponse>
Convert currency with historical data support
Sourcepub async fn convert_currency(
&self,
from: &str,
to: &str,
amount: f64,
) -> Result<ConversionResponse>
pub async fn convert_currency( &self, from: &str, to: &str, amount: f64, ) -> Result<ConversionResponse>
Convert a specific amount between two currencies (current rates)
Sourcepub async fn get_supported_currencies(
&self,
) -> Result<SupportedCurrenciesResponse>
pub async fn get_supported_currencies( &self, ) -> Result<SupportedCurrenciesResponse>
Get list of supported currencies (cached)
Sourcepub async fn is_currency_supported(&self, currency: &str) -> Result<bool>
pub async fn is_currency_supported(&self, currency: &str) -> Result<bool>
Check if a currency is supported by fetching a small set of rates
Sourcepub async fn batch_convert(
&self,
base_currency: &str,
target_currencies: &[String],
amount: f64,
) -> Result<Vec<Result<ConversionResponse>>>
pub async fn batch_convert( &self, base_currency: &str, target_currencies: &[String], amount: f64, ) -> Result<Vec<Result<ConversionResponse>>>
Batch convert multiple currency pairs efficiently
Sourcepub fn get_cache_stats(&self) -> CacheStats
pub fn get_cache_stats(&self) -> CacheStats
Get cache statistics
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear cache manually
Sourcepub async fn cleanup_cache(&self)
pub async fn cleanup_cache(&self)
Force cache cleanup of expired entries
Trait Implementations§
Source§impl Clone for ExchangeRateService
impl Clone for ExchangeRateService
Source§fn clone(&self) -> ExchangeRateService
fn clone(&self) -> ExchangeRateService
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ExchangeRateService
impl !RefUnwindSafe for ExchangeRateService
impl Send for ExchangeRateService
impl Sync for ExchangeRateService
impl Unpin for ExchangeRateService
impl !UnwindSafe for ExchangeRateService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more