1mod client;
4pub mod sequence;
5
6pub use self::{client::Client, sequence::Sequence};
7
8use std::{error, fmt};
9
10type Result<T> = std::result::Result<T, Error>;
11
12#[derive(Debug)]
14pub enum Error {
15 Input,
17 Url(url::ParseError),
19 Request(reqwest::Error),
21 Response(reqwest::Error),
23}
24
25impl error::Error for Error {
26 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
27 match self {
28 Self::Input => None,
29 Self::Url(e) => Some(e),
30 Self::Request(e) => Some(e),
31 Self::Response(e) => Some(e),
32 }
33 }
34}
35
36impl From<reqwest::Error> for Error {
37 fn from(err: reqwest::Error) -> Self {
38 if err.is_status() {
39 Error::Response(err)
40 } else {
41 Error::Request(err)
42 }
43 }
44}
45
46impl fmt::Display for Error {
47 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48 match self {
49 Self::Input => f.write_str("invalid input"),
50 Self::Url(_) => f.write_str("URL error"),
51 Self::Request(_) => f.write_str("request error"),
52 Self::Response(_) => f.write_str("response error"),
53 }
54 }
55}