icydb_core/db/executor/
mod.rs

1mod coerce;
2mod context;
3mod delete;
4mod filter;
5mod load;
6mod plan;
7mod save;
8
9pub(crate) use context::*;
10pub use delete::DeleteExecutor;
11use filter::*;
12pub use load::LoadExecutor;
13pub use save::SaveExecutor;
14
15use crate::{
16    Error,
17    db::{DbError, store::DataKey},
18};
19use thiserror::Error as ThisError;
20
21///
22/// ExecutorError
23///
24
25#[derive(Debug, ThisError)]
26pub enum ExecutorError {
27    #[error("data key exists: {0}")]
28    KeyExists(DataKey),
29
30    #[error("data key not found: {0}")]
31    KeyNotFound(DataKey),
32
33    #[error("index constraint violation: {0} ({1})")]
34    IndexViolation(String, String),
35}
36
37impl ExecutorError {
38    #[must_use]
39    /// Build an index-violation error with a formatted path/field list.
40    pub(crate) fn index_violation(path: &str, index_fields: &[&str]) -> Self {
41        Self::IndexViolation(path.to_string(), index_fields.join(", "))
42    }
43}
44
45impl From<ExecutorError> for Error {
46    fn from(err: ExecutorError) -> Self {
47        DbError::from(err).into()
48    }
49}