1pub(crate) mod chunks;
4mod client;
5mod format;
6pub mod reads;
7pub(crate) mod request;
8pub mod response;
9pub mod variants;
10
11pub use self::{client::Client, format::Format, response::Response};
12
13use std::{error, fmt};
14
15type Result<T> = std::result::Result<T, Error>;
16
17#[derive(Debug)]
19pub enum Error {
20 Input,
22 Url(url::ParseError),
24 Request(reqwest::Error),
26 Response(response::Error),
28 Decode(base64::DecodeError),
30 InvalidDataUrl,
32}
33
34impl error::Error for Error {
35 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
36 match self {
37 Self::Url(e) => Some(e),
38 Self::Request(e) => Some(e),
39 Self::Response(e) => Some(e),
40 Self::Decode(e) => Some(e),
41 _ => None,
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 Self::Decode(_) => f.write_str("decode error"),
54 Self::InvalidDataUrl => f.write_str("invalid data URL"),
55 }
56 }
57}