pub struct MapEnvironment {
pub fields: HashMap<String, Value>,
pub current_datetime: Option<Date>,
}Expand description
Flat HashMap environment for tests and simple hosts (no @ context; fixed clock in default impl).
Fields§
§fields: HashMap<String, Value>Top-level and nested values (nested via object values); keys may be dotted.
current_datetime: Option<Date>Clock source for today() / now() lookups.
Implementations§
Source§impl MapEnvironment
impl MapEnvironment
Sourcepub fn with_fields(fields: HashMap<String, Value>) -> Self
pub fn with_fields(fields: HashMap<String, Value>) -> Self
Pre-populated field map.
Sourcepub fn with_current_datetime(self, current_datetime: Option<Date>) -> Self
pub fn with_current_datetime(self, current_datetime: Option<Date>) -> Self
Override the environment clock used by today() and now().
Passing None removes the clock so calls to today() / now()
surface MissingTimezoneContextError::NotConfigured. Prefer the
readable MapEnvironment::without_clock constructor at call
sites that intend to exercise the no-clock contract.
Sourcepub fn without_clock(self) -> Self
pub fn without_clock(self) -> Self
Remove the environment clock so today() / now() produce the
MissingTimezoneContext diagnostic. Read-aloud companion to
MapEnvironment::with_current_datetime for the None case.
Trait Implementations§
Source§impl Default for MapEnvironment
Empty MapEnvironment (delegates to MapEnvironment::new).
impl Default for MapEnvironment
Empty MapEnvironment (delegates to MapEnvironment::new).
Source§impl Environment for MapEnvironment
Default clock: pinned to 2026-03-20 for deterministic tests/examples; resolves nested fields by dotted key or object walk.
impl Environment for MapEnvironment
Default clock: pinned to 2026-03-20 for deterministic tests/examples; resolves nested fields by dotted key or object walk.
Source§fn resolve_field(&self, segments: &[String]) -> Value
fn resolve_field(&self, segments: &[String]) -> Value
$a.b style path as segment list (["a","b"]); empty slice is bare $.Source§fn resolve_context(
&self,
_name: &str,
_arg: Option<&str>,
_tail: &[String],
) -> Value
fn resolve_context( &self, _name: &str, _arg: Option<&str>, _tail: &[String], ) -> Value
@name, @name('arg'), @name.tail.Source§fn current_date(&self) -> Result<Date, MissingTimezoneContextError>
fn current_date(&self) -> Result<Date, MissingTimezoneContextError>
today() per ADR 0069 D-6 — hosts MUST configure a
timezone-equivalent clock or return MissingTimezoneContextError. Read moreSource§fn current_datetime(&self) -> Result<Date, MissingTimezoneContextError>
fn current_datetime(&self) -> Result<Date, MissingTimezoneContextError>
now() per ADR 0069 D-6 — see Self::current_date for
the contract. Hosts that override one method typically override both;
returning different timezone contexts from the two paths is a host bug.Source§fn mip_valid(&self, _path: &[String]) -> Value
fn mip_valid(&self, _path: &[String]) -> Value
valid($path) — default true when not overridden.Source§fn mip_relevant(&self, _path: &[String]) -> Value
fn mip_relevant(&self, _path: &[String]) -> Value
relevant($path) — default true.Source§fn mip_readonly(&self, _path: &[String]) -> Value
fn mip_readonly(&self, _path: &[String]) -> Value
readonly($path) — default false.Source§fn mip_required(&self, _path: &[String]) -> Value
fn mip_required(&self, _path: &[String]) -> Value
required($path) — default false.Source§fn repeat_prev(&self) -> Value
fn repeat_prev(&self) -> Value
prev() in repeat scope — default null.Source§fn repeat_next(&self) -> Value
fn repeat_next(&self) -> Value
next() in repeat scope — default null.Source§fn repeat_parent(&self) -> Value
fn repeat_parent(&self) -> Value
parent() in repeat scope — default null.Source§fn locale(&self) -> Option<&str>
fn locale(&self) -> Option<&str>
locale() — default none (returns null).Source§fn date_format(&self, _style: &str) -> Option<&str>
fn date_format(&self, _style: &str) -> Option<&str>
formatDate style (short … full), when the
active locale authored one (Locale spec §2.4). Default none: built-in rendering.Source§fn runtime_meta(&self, _key: &str) -> Value
fn runtime_meta(&self, _key: &str) -> Value
runtimeMeta(key) — default null.