1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
pub type Url2Result<T> = Result<T, Url2Error>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Url2Error(Box<Url2ErrorKind>);
impl Url2Error {
pub fn kind(&self) -> &Url2ErrorKind {
&self.0
}
pub fn into_kind(self) -> Url2ErrorKind {
*self.0
}
}
impl std::error::Error for Url2Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match *self.0 {
Url2ErrorKind::UrlParseError(ref err) => Some(err),
_ => None,
}
}
}
impl std::fmt::Display for Url2Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self.0 {
Url2ErrorKind::UrlParseError(ref err) => err.fmt(f),
_ => write!(f, "Url2Error::Unknown"),
}
}
}
impl std::convert::From<Url2ErrorKind> for Url2Error {
fn from(kind: Url2ErrorKind) -> Url2Error {
Url2Error(Box::new(kind))
}
}
impl std::convert::From<url::ParseError> for Url2Error {
fn from(err: url::ParseError) -> Self {
Url2ErrorKind::UrlParseError(err).into()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Url2ErrorKind {
UrlParseError(url::ParseError),
#[doc(hidden)]
__Nonexhaustive,
}