pub struct ExchangeRateResponse {
pub result: String,
pub base_code: String,
pub last_update: i64,
pub next_update: i64,
pub conversion_rates: HashMap<String, f64>,
}
Expand description
Response from the exchange rate API for latest rates
Fields§
§result: String
Whether the request was successful
base_code: String
Base currency for the rates
last_update: i64
Last update timestamp (Unix timestamp)
next_update: i64
Next update timestamp (Unix timestamp)
conversion_rates: HashMap<String, f64>
Exchange rates relative to the base currency
Implementations§
Source§impl ExchangeRateResponse
impl ExchangeRateResponse
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if the API response indicates success
Sourcepub fn get_rate(&self, currency: &str) -> Option<f64>
pub fn get_rate(&self, currency: &str) -> Option<f64>
Get the exchange rate for a specific currency
Sourcepub fn available_currencies(&self) -> Vec<String>
pub fn available_currencies(&self) -> Vec<String>
Get all available currency codes
Sourcepub fn currency_count(&self) -> usize
pub fn currency_count(&self) -> usize
Get the number of supported currencies
Sourcepub fn to_historical(&self, date: &str) -> HistoricalRateResponse
pub fn to_historical(&self, date: &str) -> HistoricalRateResponse
Convert to historical response format
Trait Implementations§
Source§impl Clone for ExchangeRateResponse
impl Clone for ExchangeRateResponse
Source§fn clone(&self) -> ExchangeRateResponse
fn clone(&self) -> ExchangeRateResponse
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 moreSource§impl Debug for ExchangeRateResponse
impl Debug for ExchangeRateResponse
Source§impl<'de> Deserialize<'de> for ExchangeRateResponse
impl<'de> Deserialize<'de> for ExchangeRateResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ExchangeRateResponse
impl RefUnwindSafe for ExchangeRateResponse
impl Send for ExchangeRateResponse
impl Sync for ExchangeRateResponse
impl Unpin for ExchangeRateResponse
impl UnwindSafe for ExchangeRateResponse
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