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
33
34
35
36
37
38
39
40
41
42
43
44
use std::io;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
#[error(transparent)]
pub struct Error {
#[from]
inner: Box<ErrorInner>,
}
#[derive(Debug, Error)]
enum ErrorInner {
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
Bincode(#[from] bincode::Error),
}
impl From<io::Error> for Error {
fn from(e: io::Error) -> Error {
let e: ErrorInner = e.into();
e.into()
}
}
impl From<bincode::Error> for Error {
fn from(e: bincode::Error) -> Error {
let e: ErrorInner = e.into();
e.into()
}
}
impl From<ErrorInner> for Error {
fn from(e: ErrorInner) -> Error {
Box::new(e).into()
}
}