1use core::fmt;
2
3use crate::uri;
4
5pub type Result<T> = core::result::Result<T, Error>;
6
7#[derive(Debug)]
8pub enum Error {
9 Uri(uri::InvalidUri),
10
11 UriParts(uri::InvalidUriParts),
12 InvalidStatusCode,
13}
14
15impl fmt::Display for Error {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 Error::InvalidStatusCode => f.write_str("invalid status code"),
19 Error::UriParts(e) => write!(f, "{e}"),
20 Error::Uri(e) => write!(f, "{e}"),
21 }
22 }
23}
24
25impl From<uri::InvalidUri> for Error {
26 fn from(err: uri::InvalidUri) -> Error {
27 Error::Uri(err)
28 }
29}
30
31impl From<uri::InvalidUriParts> for Error {
32 fn from(err: uri::InvalidUriParts) -> Error {
33 Error::UriParts(err)
34 }
35}
36
37impl From<core::convert::Infallible> for Error {
38 fn from(err: core::convert::Infallible) -> Error {
39 match err {}
40 }
41}