Skip to main content

crux_kv/
error.rs

1use facet::Facet;
2use serde::{Deserialize, Serialize};
3use thiserror::Error;
4
5/// Error type for `KeyValue` operations
6#[derive(Facet, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Error)]
7#[serde(rename_all = "camelCase")]
8#[repr(C)]
9pub enum KeyValueError {
10    #[error("IO error: {message}")]
11    Io { message: String },
12    #[error("timeout")]
13    Timeout,
14    #[error("cursor not found")]
15    CursorNotFound,
16    #[error("other error: {message}")]
17    Other { message: String },
18}
19
20pub type Result<T> = core::result::Result<T, KeyValueError>;
21pub type StatusResult = Result<bool>;
22pub type DataResult = Result<Option<Vec<u8>>>;
23pub type ListResult = Result<(Vec<String>, u64)>;