Skip to main content

sim_value/
lib.rs

1//! Ergonomic construction and access for kernel `Expr` data.
2//!
3//! The kernel `Expr` enum is bare data with no ergonomic surface. This crate
4//! keeps construction, field access, kind labels, immutable updates, and
5//! `k`/`i` path-addressing helpers in one shared home. It
6//! depends only on `sim-kernel` and adds data ergonomics, not runtime behavior,
7//! so it does not touch the kernel boundary.
8//!
9//! - [`build`]: constructors (`sym`, `int`, `float`, `text`, `list`, `map`, ...);
10//! - [`capability_names_from_expr`]: parses capability-name expressions;
11//! - [`access`]: reading and immutable updates (`field`, `field_any`, `set`,
12//!   `set_strict`, `remove`, ...);
13//! - [`edit`]: side-effect-free exact and line-range text edits;
14//! - [`kind`]: the one `Expr` variant classifier (`expr_kind`);
15//! - [`path`]: one value-addressing primitive (`Path`, `get`, `set_at`).
16//!
17//! # Example
18//!
19//! ```
20//! use sim_value::access::{field, set};
21//! use sim_value::build::{int, map, sym};
22//!
23//! let value = map(vec![("a", int(1)), ("b", int(2))]);
24//! assert_eq!(field(&value, "a"), Some(&int(1)));
25//!
26//! let updated = set(&value, "a", int(9));
27//! assert_eq!(field(&updated, "a"), Some(&int(9)));
28//! assert_eq!(field(&updated, "b"), Some(&int(2))); // siblings preserved
29//! let _ = sym("ok");
30//! ```
31
32#![forbid(unsafe_code)]
33#![deny(missing_docs)]
34
35pub mod access;
36pub mod build;
37pub mod capability;
38pub mod edit;
39pub mod kind;
40pub mod path;
41
42pub use capability::capability_names_from_expr;
43
44#[cfg(test)]
45mod tests;