sketches_rust/
error.rs

1use std::{fmt, io};
2
3#[derive(Debug)]
4pub enum Error {
5    InvalidArgument(&'static str),
6    IoError(io::ErrorKind),
7}
8
9impl fmt::Display for Error {
10    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11        match *self {
12            Error::InvalidArgument(arg) => write!(f, "Invalid argument: {}", arg),
13            Error::IoError(ref cause) => write!(f, "Io Error: {}", cause),
14        }
15    }
16}
17
18impl From<io::Error> for Error {
19    fn from(error: io::Error) -> Self {
20        Error::IoError(error.kind())
21    }
22}