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