Struct fixerio::SyncApi
[−]
[src]
pub struct SyncApi { /* fields omitted */ }
Synchronous API for sending requests.
Methods
impl SyncApi
[src]
fn new() -> Result<Self, Error>
Create a new instance.
fn get(&self, conf: &Config) -> Result<Exchange, Error>
Perform request.
Examples
use fixerio::{Config, Currency, SyncApi}; use std::time::Duration; fn main() { let api = SyncApi::new().expect("Error creating API"); let config = Config::new(Currency::USD); let rates = api.get(&config).expect("Error retrieving rates"); println!("{:?}", rates); }
fn get_timeout(
&self,
conf: &Config,
duration: Duration
) -> Result<Option<Exchange>, Error>
&self,
conf: &Config,
duration: Duration
) -> Result<Option<Exchange>, Error>
Perform request with timeout.
Examples
use fixerio::{Config, Currency, SyncApi}; use std::time::Duration; fn main() { let api = SyncApi::new().expect("Error creating API"); let config = Config::new(Currency::USD); let rates = api.get_timeout(&config, Duration::from_secs(5)).expect("Error retrieving rates"); match rates { Some(x) => println!("{:?}", x), _ => println!("Request timed out") }; }