summaryrefslogtreecommitdiffstats
path: root/src/errors.rs
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2020-10-07 05:47:39 -0400
committerPaul Woolcock <paul@woolcock.us>2020-10-07 09:06:13 -0400
commit02ca0a89515413ac9fb3b655de2f21f6a711e0f2 (patch)
tree004bcd9f88eca168e10e1ac85c5987fdd6769fcf /src/errors.rs
parent04b5b54212629f058bdab1ba55c89a3d417e0454 (diff)
Add basic async client
This adds a module, accessible by compiling with `--features async`, that provides an `elefren::async::Client`. The client is runtime-agnostic, and currently only provides unauthenticated access, see the docs for the full list of methods that can be performed* with this client. * note that some API calls are publicly available by default, but can be changed via instance settings to not be publicly accessible
Diffstat (limited to 'src/errors.rs')
-rw-r--r--src/errors.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs
index 2813bfd..6b58d05 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -5,8 +5,12 @@ use std::{error, fmt, io::Error as IoError};
use ::toml::de::Error as TomlDeError;
#[cfg(feature = "toml")]
use ::toml::ser::Error as TomlSerError;
+#[cfg(feature = "async")]
+use async_native_tls::Error as TlsError;
#[cfg(feature = "env")]
use envy::Error as EnvyError;
+#[cfg(feature = "async")]
+use http_types::Error as HttpTypesError;
use hyper_old_types::Error as HeaderParseError;
use reqwest::{header::ToStrError as HeaderStrError, Error as HttpError, StatusCode};
use serde_json::Error as SerdeError;
@@ -64,6 +68,12 @@ pub enum Error {
SerdeQs(SerdeQsError),
/// WebSocket error
WebSocket(WebSocketError),
+ #[cfg(feature = "async")]
+ /// http-types error
+ HttpTypes(HttpTypesError),
+ #[cfg(feature = "async")]
+ /// TLS error
+ Tls(TlsError),
/// Other errors
Other(String),
}
@@ -99,6 +109,10 @@ impl error::Error for Error {
Error::ClientSecretRequired => return None,
Error::AccessTokenRequired => return None,
Error::MissingField(_) => return None,
+ #[cfg(feature = "async")]
+ Error::HttpTypes(..) => return None,
+ #[cfg(feature = "async")]
+ Error::Tls(ref e) => e,
Error::Other(..) => return None,
})
}
@@ -149,6 +163,8 @@ from! {
#[cfg(feature = "env")] EnvyError, Envy,
SerdeQsError, SerdeQs,
WebSocketError, WebSocket,
+ #[cfg(feature = "async")] HttpTypesError, HttpTypes,
+ #[cfg(feature = "async")] TlsError, Tls,
String, Other,
}