use std::io;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Io(io::Error),
UnknownString(String),
InvalidCursor(u64),
NotImplemented(&'static str),
Other(String),
NotFound,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Io(err) => write!(f, "I/O error: {err}"),
Error::UnknownString(s) => write!(f, "unknown string: {s}"),
Error::InvalidCursor(id) => write!(f, "invalid cursor id: {id}"),
Error::NotImplemented(msg) => write!(f, "not implemented: {msg}"),
Error::Other(msg) => write!(f, "{msg}"),
Error::NotFound => write!(f, "not found"),
}
}
}
impl std::error::Error for Error {}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Error::Io(err)
}
}
#[cfg(all(feature = "temporal", not(target_arch = "wasm32")))]
impl From<nervusdb_temporal::Error> for Error {
fn from(err: nervusdb_temporal::Error) -> Self {
Error::Other(err.to_string())
}
}