parent
c2280b350e
commit
907da2f20a
@ -1,49 +0,0 @@
|
|||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
|
||||||
use std::io::Error as IoError;
|
|
||||||
|
|
||||||
use regex::Error as RegexError;
|
|
||||||
|
|
||||||
pub type MkrootResult<T> = Result<T, MkrootError>;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum MkrootError {
|
|
||||||
Io(IoError),
|
|
||||||
Regex(RegexError),
|
|
||||||
Custom(String),
|
|
||||||
Empty,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<IoError> for MkrootError {
|
|
||||||
fn from(e: IoError) -> MkrootError {
|
|
||||||
MkrootError::Io(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<RegexError> for MkrootError {
|
|
||||||
fn from(e: RegexError) -> MkrootError {
|
|
||||||
MkrootError::Regex(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<String> for MkrootError {
|
|
||||||
fn from(e: String) -> MkrootError {
|
|
||||||
MkrootError::Custom(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<()> for MkrootError {
|
|
||||||
fn from(_: ()) -> MkrootError {
|
|
||||||
MkrootError::Empty
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for MkrootError {
|
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
|
||||||
match *self {
|
|
||||||
MkrootError::Io(ref e) => Display::fmt(e, f),
|
|
||||||
MkrootError::Regex(ref e) => Display::fmt(e, f),
|
|
||||||
MkrootError::Custom(ref e) => Display::fmt(e, f),
|
|
||||||
MkrootError::Empty => Display::fmt("Empty", f),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue