3 new primitives, registered in workspace members (39 crates total): - kei-diff (9 files, 27 tests): Structural JSON diff RFC 6902 subset (add/remove/replace). Pure computation. Index-based array diff (not LCS) matches drift-detection semantics. Round-trip property verified on 15+ fixtures. Zero sibling deps — pure utility. - kei-scheduler (12 files, 16 tests): Durable task scheduler (cron / at / interval) primitive. Engine-native (SCHEDULER_SCHEMA on kei-entity-store). Name-unique via custom migration. compute_next pure fn + CLI tick for external executor. - kei-watch (12 files, 30 tests): Filesystem watcher thin wrapper around notify 8.x. Sync API (no tokio). 50ms debounce. Cross-platform rename handling (macOS Modify(Name(Both)) vs Linux From/To pair). All crate-local [workspace] tables removed. Registered in _primitives/_rust/Cargo.toml. cargo check --workspace clean. Constructor Pattern: all source files <=200 LOC, all functions <=30 LOC. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37 lines
1.4 KiB
Rust
37 lines
1.4 KiB
Rust
//! `ApplyError` — structured failure reasons for `apply()`.
|
|
//!
|
|
//! Kept in its own module so `apply.rs` stays focused on the algorithm
|
|
//! and each file stays within Constructor Pattern limits.
|
|
|
|
use std::fmt;
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub enum ApplyError {
|
|
InvalidPointer(String),
|
|
MissingParent(String),
|
|
MissingTarget(String),
|
|
IndexOutOfBounds { path: String, index: usize, len: usize },
|
|
TypeMismatch { path: String, expected: &'static str },
|
|
CannotAddToRoot,
|
|
CannotRemoveRoot,
|
|
}
|
|
|
|
impl fmt::Display for ApplyError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::InvalidPointer(p) => write!(f, "invalid JSON pointer: {p:?}"),
|
|
Self::MissingParent(p) => write!(f, "missing parent at {p:?}"),
|
|
Self::MissingTarget(p) => write!(f, "missing target at {p:?}"),
|
|
Self::IndexOutOfBounds { path, index, len } => {
|
|
write!(f, "index {index} out of bounds (len {len}) at {path:?}")
|
|
}
|
|
Self::TypeMismatch { path, expected } => {
|
|
write!(f, "type mismatch at {path:?}: expected {expected}")
|
|
}
|
|
Self::CannotAddToRoot => write!(f, "cannot 'add' to root (use 'replace')"),
|
|
Self::CannotRemoveRoot => write!(f, "cannot 'remove' root"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for ApplyError {}
|