Skip to main content

MapEnvironment

Struct MapEnvironment 

Source
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

Source

pub fn new() -> Self

Empty field map.

Source

pub fn with_fields(fields: HashMap<String, Value>) -> Self

Pre-populated field map.

Source

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.

Source

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).

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
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.

Source§

fn resolve_field(&self, segments: &[String]) -> Value

Resolve $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

Resolve @name, @name('arg'), @name.tail.
Source§

fn current_date(&self) -> Result<Date, MissingTimezoneContextError>

Calendar date for today() per ADR 0069 D-6 — hosts MUST configure a timezone-equivalent clock or return MissingTimezoneContextError. Read more
Source§

fn current_datetime(&self) -> Result<Date, MissingTimezoneContextError>

Date-time for 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

valid($path) — default true when not overridden.
Source§

fn mip_relevant(&self, _path: &[String]) -> Value

relevant($path) — default true.
Source§

fn mip_readonly(&self, _path: &[String]) -> Value

readonly($path) — default false.
Source§

fn mip_required(&self, _path: &[String]) -> Value

required($path) — default false.
Source§

fn repeat_prev(&self) -> Value

prev() in repeat scope — default null.
Source§

fn repeat_next(&self) -> Value

next() in repeat scope — default null.
Source§

fn repeat_parent(&self) -> Value

parent() in repeat scope — default null.
Source§

fn locale(&self) -> Option<&str>

Active locale code for locale() — default none (returns null).
Source§

fn date_format(&self, _style: &str) -> Option<&str>

The Locale document’s pattern for a 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

Runtime metadata value for runtimeMeta(key) — default null.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.