use maildir::MailEntryError; use mailparse::MailParseError; use protobuf::Error as PBError; pub type Result = std::result::Result; #[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 for Error { fn from(io_err: std::io::Error) -> Self { Error::IoError(io_err) } } impl From for Error { fn from(me_err: MailEntryError) -> Self { Error::MailEntryError(me_err) } } impl From for Error { fn from(mp_err: MailParseError) -> Self { Error::MailEntryError(MailEntryError::ParseError(mp_err)) } } impl From for Error { fn from(pb_err: PBError) -> Self { Error::Protobuf(pb_err) } }