feat: std error compatible error

This commit is contained in:
DCjanus
2021-12-25 02:41:45 +08:00
parent 679ccc43fa
commit 409a583b22
8 changed files with 210 additions and 191 deletions

20
src/result.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fmt::{Debug, Display, Formatter};
pub type Result<T> = std::result::Result<T, MagickError>;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub struct MagickError(pub &'static str);
impl From<&'static str> for MagickError {
fn from(s: &'static str) -> Self {
MagickError(s)
}
}
impl Display for MagickError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(self.0, f)
}
}
impl std::error::Error for MagickError {}