1use std::io;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug)]
10pub enum Error {
11 Io(io::Error),
13 UnknownString(String),
15 InvalidCursor(u64),
17 NotImplemented(&'static str),
19 Other(String),
21 NotFound,
23}
24
25impl std::fmt::Display for Error {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 match self {
28 Error::Io(err) => write!(f, "I/O error: {err}"),
29 Error::UnknownString(s) => write!(f, "unknown string: {s}"),
30 Error::InvalidCursor(id) => write!(f, "invalid cursor id: {id}"),
31 Error::NotImplemented(msg) => write!(f, "not implemented: {msg}"),
32 Error::Other(msg) => write!(f, "{msg}"),
33 Error::NotFound => write!(f, "not found"),
34 }
35 }
36}
37
38impl std::error::Error for Error {}
39
40impl From<io::Error> for Error {
41 fn from(err: io::Error) -> Self {
42 Error::Io(err)
43 }
44}
45
46#[cfg(all(feature = "temporal", not(target_arch = "wasm32")))]
47impl From<nervusdb_temporal::Error> for Error {
48 fn from(err: nervusdb_temporal::Error) -> Self {
49 Error::Other(err.to_string())
50 }
51}