Expand description
Table and Dir substrate for layered SIM configuration.
Configuration is plain kernel data: a ConfigTable is one library’s
Expr::Map, and a ConfigDir maps library ids to those tables. This crate
provides the data model, merge/provenance rules, shape-backed defaults,
typed read views, and safe path helpers used by loaders and codecs without
introducing a parallel configuration value enum.
§Example
use sim_config::{ConfigDir, ConfigLayer, ConfigSource, merge_layers};
use sim_kernel::{Expr, Symbol};
use sim_value::build::{entry, map, text};
let lib = Symbol::qualified("sim", "cookbook");
let lower = ConfigDir::one(lib.clone(), map(vec![("mode", text("built-in"))])).unwrap();
let upper = ConfigDir::one(lib.clone(), map(vec![("mode", text("work"))])).unwrap();
let effective = merge_layers(&[
ConfigLayer::new(ConfigSource::BuiltIn { lib: lib.clone() }, lower),
ConfigLayer::new(ConfigSource::Explicit { label: "work".into() }, upper),
]);
let table = effective.dir.table(&lib).unwrap();
assert_eq!(sim_value::access::field(&table.table, "mode"), Some(&Expr::String("work".into())));
assert_eq!(effective.trace[0].key, "mode");
let _ = entry("ok", Expr::Bool(true));Re-exports§
pub use merge::ConfigLayer;pub use merge::EffectiveConfig;pub use merge::MergeTrace;pub use merge::merge_layers;pub use path::ConfigRoots;pub use path::lib_config_path;pub use report::ConfigReport;pub use report::ConfigReportEntry;pub use shape::ConfigSecretField;pub use shape::ConfigShape;pub use shape::ConfigShapeResult;pub use shape::LibConfigDefaults;pub use source::ConfigSource;pub use source::ProbeMode;pub use table::ConfigDir;pub use table::ConfigTable;pub use table::lib_symbol_from_str;pub use view::ConfigView;
Modules§
- merge
- Layer merging and field-level provenance.
- path
- Safe path helpers for config roots and per-library files.
- report
- Report model for effective config provenance.
- shape
- Shape-backed configuration defaults and validation.
- source
- Configuration source descriptors.
- table
- Config Table and Dir data types.
- view
- Typed read view over a config table.
Enums§
- Config
Error - Error reported by config table, view, and path helpers.
Type Aliases§
- Config
Result - Result type used by
sim-confighelpers.