diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/src/error.rs b/src/error.rs index fc0a21a..0c0167f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,9 +1,6 @@ -use std::borrow::Cow; - use maildir::MailEntryError; use mailparse::MailParseError; -use serde::ser::SerializeStruct as _; -use serde_json::Error as JSONError; +use protobuf::Error as PBError; pub type Result<T> = std::result::Result<T, Error>; @@ -13,7 +10,7 @@ pub enum Error { MailEntryError(MailEntryError), SortOrder(String), Setuid(String), - JSONError(JSONError), + Protobuf(PBError), PathError { msg: String, path: String }, } @@ -25,25 +22,6 @@ impl std::fmt::Display for Error { impl std::error::Error for Error {} -impl serde::Serialize for Error { - fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - let mut state = serializer.serialize_struct("Error", 1)?; - let err_str: Cow<str> = match self { - Error::IoError(e) => Cow::Owned(e.to_string()), - Error::MailEntryError(e) => Cow::Owned(e.to_string()), - Error::SortOrder(s) => Cow::Borrowed(s), - Error::Setuid(s) => Cow::Borrowed(s), - Error::JSONError(e) => Cow::Owned(e.to_string()), - Error::PathError { msg, path } => Cow::Owned(format!("{} {:?}", msg, path)), - }; - state.serialize_field("error", &err_str)?; - state.end() - } -} - impl From<std::io::Error> for Error { fn from(io_err: std::io::Error) -> Self { Error::IoError(io_err) @@ -62,8 +40,8 @@ impl From<MailParseError> for Error { } } -impl From<JSONError> for Error { - fn from(j_err: JSONError) -> Self { - Error::JSONError(j_err) +impl From<PBError> for Error { + fn from(pb_err: PBError) -> Self { + Error::Protobuf(pb_err) } } |