blob: 0c0167f3b774f57308546b430cca9ea607d5a1d7 (
plain)
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
|
use maildir::MailEntryError;
use mailparse::MailParseError;
use protobuf::Error as PBError;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
IoError(std::io::Error),
MailEntryError(MailEntryError),
SortOrder(String),
Setuid(String),
Protobuf(PBError),
PathError { msg: String, path: String },
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
write!(f, "{:?}", self)
}
}
impl std::error::Error for Error {}
impl From<std::io::Error> for Error {
fn from(io_err: std::io::Error) -> Self {
Error::IoError(io_err)
}
}
impl From<MailEntryError> for Error {
fn from(me_err: MailEntryError) -> Self {
Error::MailEntryError(me_err)
}
}
impl From<MailParseError> for Error {
fn from(mp_err: MailParseError) -> Self {
Error::MailEntryError(MailEntryError::ParseError(mp_err))
}
}
impl From<PBError> for Error {
fn from(pb_err: PBError) -> Self {
Error::Protobuf(pb_err)
}
}
|