1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::{fmt, io};

#[derive(Debug)]
pub enum Error {
    InvalidArgument(&'static str),
    IoError(io::ErrorKind),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            Error::InvalidArgument(arg) => write!(f, "Invalid argument: {}", arg),
            Error::IoError(ref cause) => write!(f, "Io Error: {}", cause),
        }
    }
}

impl From<io::Error> for Error {
    fn from(error: io::Error) -> Self {
        Error::IoError(error.kind())
    }
}