#[cfg(feature = "http_client")]
mod http;
#[cfg(feature = "http_client")]
pub use http::*;
#[cfg(feature = "signalr_client")]
mod signalr;
#[cfg(feature = "signalr_client")]
pub use signalr::*;
#[repr(u8)]
#[derive(Debug)]
pub enum ApiError {
#[cfg(feature = "http_client")]
Http(reqwest::Error),
#[cfg(feature = "signalr_client")]
Other(String),
Serde(serde_json::Error),
#[cfg(feature = "signalr_client")]
WebSocket(ezsockets::Error),
}
impl From<serde_json::Error> for ApiError {
fn from(err: serde_json::Error) -> Self { Self::Serde(err) }
}
#[cfg(feature = "http_client")]
impl From<reqwest::Error> for ApiError {
fn from(err: reqwest::Error) -> Self { Self::Http(err) }
}
#[cfg(feature = "http_client")]
impl From<racal::reqwest::ApiError> for ApiError {
fn from(err: racal::reqwest::ApiError) -> Self {
match err {
racal::reqwest::ApiError::Reqwest(e) => Self::Http(e),
racal::reqwest::ApiError::Serde(e) => Self::Serde(e),
}
}
}
#[cfg(feature = "signalr_client")]
impl From<ezsockets::Error> for ApiError {
fn from(err: ezsockets::Error) -> Self { Self::WebSocket(err) }
}