32 lines
823 B
Rust
32 lines
823 B
Rust
|
|
||
|
pub type Result<T> = std::result::Result<T, GeoffreyDBError>;
|
||
|
|
||
|
#[derive(Debug)]
|
||
|
pub enum GeoffreyDBError {
|
||
|
SledError(sled::Error),
|
||
|
SerdeJsonError(serde_json::Error),
|
||
|
}
|
||
|
|
||
|
impl std::error::Error for GeoffreyDBError {}
|
||
|
|
||
|
impl std::fmt::Display for GeoffreyDBError {
|
||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||
|
match self {
|
||
|
GeoffreyDBError::SledError(e) => write!(f, "Sled Error: {}", e),
|
||
|
GeoffreyDBError::SerdeJsonError(e) => write!(f, "Serde JSON Error: {}", e)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<sled::Error> for GeoffreyDBError {
|
||
|
fn from(e: sled::Error) -> Self {
|
||
|
GeoffreyDBError::SledError(e)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<serde_json::Error> for GeoffreyDBError {
|
||
|
fn from(e: serde_json::Error) -> Self {
|
||
|
GeoffreyDBError::SerdeJsonError(e)
|
||
|
}
|
||
|
}
|