1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
use hyper; use serde; use serde_json; #[derive(Debug)] pub enum Error<T> { Hyper(hyper::Error), Serde(serde_json::Error), ApiError(ApiError<T>), } #[derive(Debug)] pub struct ApiError<T> { pub code: hyper::StatusCode, pub content: Option<T>, } impl<'de, T> From<(hyper::StatusCode, &'de [u8])> for Error<T> where T: serde::Deserialize<'de> { fn from(e: (hyper::StatusCode, &'de [u8])) -> Self { if e.1.len() == 0 { return Error::ApiError(ApiError{ code: e.0, content: None, }); } match serde_json::from_slice::<T>(e.1) { Ok(t) => Error::ApiError(ApiError{ code: e.0, content: Some(t), }), Err(e) => { Error::from(e) } } } } impl<T> From<hyper::Error> for Error<T> { fn from(e: hyper::Error) -> Self { return Error::Hyper(e) } } impl<T> From<serde_json::Error> for Error<T> { fn from(e: serde_json::Error) -> Self { return Error::Serde(e) } } use super::models::*; mod crypto_api; pub use self::crypto_api::{ CryptoApi, CryptoApiClient }; mod forex_currencies_api; pub use self::forex_currencies_api::{ ForexCurrenciesApi, ForexCurrenciesApiClient }; mod reference_api; pub use self::reference_api::{ ReferenceApi, ReferenceApiClient }; mod stocks_equities_api; pub use self::stocks_equities_api::{ StocksEquitiesApi, StocksEquitiesApiClient }; pub mod configuration; pub mod client;