icydb_core/db/executor/
mod.rs1mod coerce;
2mod context;
3mod delete;
4mod filter;
5mod load;
6mod plan;
7mod save;
8mod unique;
9mod upsert;
10
11pub(crate) use context::*;
12pub use delete::DeleteExecutor;
13pub use load::LoadExecutor;
14pub use save::SaveExecutor;
15pub(crate) use unique::resolve_unique_pk;
16pub use upsert::{UniqueIndexHandle, UpsertExecutor, UpsertResult};
17
18use crate::{
19 Error,
20 db::{DbError, store::DataKey},
21};
22use filter::*;
23use thiserror::Error as ThisError;
24
25#[derive(Debug, ThisError)]
30pub enum ExecutorError {
31 #[error("data key exists: {0}")]
32 KeyExists(DataKey),
33
34 #[error("data key not found: {0}")]
35 KeyNotFound(DataKey),
36
37 #[error("index constraint violation: {0} ({1})")]
38 IndexViolation(String, String),
39
40 #[error("index not found: {0} ({1})")]
41 IndexNotFound(String, String),
42
43 #[error("index not unique: {0} ({1})")]
44 IndexNotUnique(String, String),
45
46 #[error("index key missing: {0} ({1})")]
47 IndexKeyMissing(String, String),
48
49 #[error("index corrupted: {0} ({1}) -> {2} keys")]
50 IndexCorrupted(String, String, usize),
51
52 #[error("primary key type mismatch: expected {0}, got {1}")]
53 KeyTypeMismatch(String, String),
54
55 #[error("primary key out of range for {0}: {1}")]
56 KeyOutOfRange(String, String),
57}
58
59impl ExecutorError {
60 #[must_use]
61 pub(crate) fn index_violation(path: &str, index_fields: &[&str]) -> Self {
63 Self::IndexViolation(path.to_string(), index_fields.join(", "))
64 }
65}
66
67impl From<ExecutorError> for Error {
68 fn from(err: ExecutorError) -> Self {
69 DbError::from(err).into()
70 }
71}