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
pub type ForensicResult<T> = Result<T, ForensicError>;

#[derive(Debug)]
pub enum ForensicError {
    PermissionError,
    NoMoreData,
    Other(String),
    Missing,
    BadFormat,
    Io(std::io::Error),
    CastError
}

impl Clone for ForensicError {
    fn clone(&self) -> Self {
        match self {
            Self::PermissionError => Self::PermissionError,
            Self::CastError => Self::CastError,
            Self::NoMoreData => Self::NoMoreData,
            Self::Other(arg0) => Self::Other(arg0.clone()),
            Self::Missing => Self::Missing,
            Self::BadFormat => Self::BadFormat,
            Self::Io(e) => Self::Io(std::io::Error::new(e.kind().clone(), e.to_string())),
        }
    }
}

impl From<std::io::Error> for ForensicError {
    fn from(e: std::io::Error) -> Self {
        ForensicError::Io(e)
    }
}