1#[derive(Debug)]
2pub enum Error {
3 Io(std::io::Error),
4 Other(String),
5 Unknown(Box<dyn std::error::Error>),
6}
7
8unsafe impl Send for Error {}
9unsafe impl Sync for Error {}
10
11impl std::fmt::Display for Error {
12 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
13 match self {
14 Self::Io(error) => write!(f, "I/O error: {}", error),
15 Self::Other(error) => write!(f, "Error: {}", error),
16
17 Self::Unknown(error) => write!(f, "Unknown error: {}", error),
18 }
19 }
20}
21
22impl std::error::Error for Error {
23 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
24 None
25 }
26}
27
28impl From<std::io::Error> for Error {
29 fn from(error: std::io::Error) -> Self {
30 Self::Io(error)
31 }
32}
33
34impl From<Box<dyn std::error::Error + Sync + Send>> for Error {
35 fn from(error: Box<dyn std::error::Error + Sync + Send>) -> Self {
36 Self::Unknown(error)
37 }
38}