1use std::{
4 convert::From,
5 error::Error as StdError,
6 fmt,
7 fmt::{Debug, Display},
8 io::Error as IoError,
9};
10
11#[derive(Debug)]
13pub enum Error {
14 Custom(String),
16 IO(String),
18}
19
20impl From<IoError> for Error {
22 fn from(e: IoError) -> Error {
23 Error::IO(e.to_string())
24 }
25}
26
27impl Display for Error {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 Error::Custom(s) => write!(f, "{}", s),
32 Error::IO(s) => write!(f, "{}", s),
33 }
34 }
35}
36
37impl StdError for Error {}