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
use std::io;
use std::sync::PoisonError;
pub type DbResult<T> = Result<T, DbError>;
#[derive(Debug)]
pub enum DbError {
Unexpected(&'static str),
Io(io::Error),
Bincode(bincode::Error),
MutexPoisoned,
}
impl From<bincode::Error> for DbError {
fn from(err: bincode::Error) -> Self {
Self::Bincode(err)
}
}
impl From<io::Error> for DbError {
fn from(err: io::Error) -> Self {
Self::Io(err)
}
}
impl<G> From<PoisonError<G>> for DbError {
fn from(_: PoisonError<G>) -> Self {
Self::MutexPoisoned
}
}