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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use std::error::Error as StdError;
use std::fmt;
use std::str::Utf8Error;
use quick_xml::errors::Error as XmlError;
#[derive(Debug)]
pub enum Error {
Utf8(Utf8Error),
Xml(XmlError),
InvalidStartTag,
Eof,
#[cfg(feature = "from_url")]
UrlRequest(::reqwest::Error),
#[cfg(feature = "from_url")]
Io(::std::io::Error),
}
impl StdError for Error {
fn description(&self) -> &str {
match *self {
Error::Utf8(ref err) => err.description(),
Error::Xml(ref err) => err.description(),
Error::InvalidStartTag => "the input did not begin with an rss tag",
Error::Eof => "reached end of input without finding a complete channel",
#[cfg(feature = "from_url")]
Error::UrlRequest(ref err) => err.description(),
#[cfg(feature = "from_url")]
Error::Io(ref err) => err.description(),
}
}
fn cause(&self) -> Option<&StdError> {
match *self {
Error::Utf8(ref err) => Some(err),
Error::Xml(ref err) => Some(err),
#[cfg(feature = "from_url")]
Error::UrlRequest(ref err) => Some(err),
#[cfg(feature = "from_url")]
Error::Io(ref err) => Some(err),
_ => None,
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Utf8(ref err) => err.fmt(f),
Error::Xml(ref err) => err.fmt(f),
Error::InvalidStartTag => write!(f, "the input did not begin with an rss tag"),
Error::Eof => write!(f, "reached end of input without finding a complete channel"),
#[cfg(feature = "from_url")]
Error::UrlRequest(ref err) => err.fmt(f),
#[cfg(feature = "from_url")]
Error::Io(ref err) => err.fmt(f),
}
}
}
impl From<XmlError> for Error {
fn from(err: XmlError) -> Error {
Error::Xml(err)
}
}
impl From<Utf8Error> for Error {
fn from(err: Utf8Error) -> Error {
Error::Utf8(err)
}
}
#[cfg(feature = "from_url")]
impl From<::reqwest::Error> for Error {
fn from(err: ::reqwest::Error) -> Error {
Error::UrlRequest(err)
}
}
#[cfg(feature = "from_url")]
impl From<::std::io::Error> for Error {
fn from(err: ::std::io::Error) -> Error {
Error::Io(err)
}
}