Skip to main content

FormspecEnvironment

Struct FormspecEnvironment 

Source
pub struct FormspecEnvironment {
    pub data: HashMap<String, Value>,
    pub instances: HashMap<String, Value>,
    pub mip_states: HashMap<String, MipState>,
    pub variables: HashMap<String, Value>,
    pub repeat_context: Option<RepeatContext>,
    pub current_datetime: Option<Date>,
    pub locale: Option<String>,
    pub date_formats: HashMap<String, String>,
    pub meta: HashMap<String, Value>,
}
Expand description

A full-featured environment for FEL evaluation within a Formspec engine.

Supports:

  • Field resolution via $field.path (walks nested data dict)
  • Named instances via @instance('name')
  • Repeat context via @current, @index, @count
  • MIP state queries via valid(), relevant(), etc.
  • Environment variables via @variableName when no host catalog is active
  • Mapping-style context via host-specific Environment implementations
  • Locale via locale() and pluralCategory()
  • Runtime metadata via runtimeMeta(key)

Fields§

§data: HashMap<String, Value>

Primary data dict — backs $field references.

§instances: HashMap<String, Value>

Named secondary instances — backs @instance('name').

§mip_states: HashMap<String, MipState>

MIP states per dotted field path.

§variables: HashMap<String, Value>

Environment variables — backs @variableName when no host catalog is active.

§repeat_context: Option<RepeatContext>

Current repeat context (if inside a repeat iteration).

§current_datetime: Option<Date>

Current runtime date for today()/now().

§locale: Option<String>

Active locale code (BCP 47) — backs locale() and default for pluralCategory().

§date_formats: HashMap<String, String>

The active Locale document’s formats.date — a pattern per formatDate style name (short … full) that replaces the built-in rendering of that style.

§meta: HashMap<String, Value>

Runtime metadata bag — backs runtimeMeta(key).

Implementations§

Source§

impl FormspecEnvironment

Source

pub fn new() -> Self

Empty environment (no data, instances, or repeat context).

Source

pub fn set_field(&mut self, path: &str, value: TypeValue)

Set a field value by dotted path (e.g., “address.city”).

Source

pub fn set_instance(&mut self, name: &str, value: TypeValue)

Set a named instance.

Source

pub fn set_mip(&mut self, path: &str, state: MipState)

Set MIP state for a field path.

Source

pub fn set_variable(&mut self, name: &str, value: TypeValue)

Set a variable value.

Source

pub fn set_locale(&mut self, code: &str)

Set the active locale code (BCP 47).

Source

pub fn set_date_format(&mut self, style: &str, pattern: &str)

Set the pattern a formatDate style renders with (Locale formats.date.<style>).

Source

pub fn set_meta(&mut self, key: &str, value: TypeValue)

Set a runtime metadata value.

Source

pub fn set_now_from_iso(&mut self, iso: &str)

Set the current runtime datetime from an ISO string.

Source

pub fn push_repeat( &mut self, current: TypeValue, index: usize, count: usize, collection: Vec<TypeValue>, )

Enter a repeat context.

Source

pub fn pop_repeat(&mut self)

Leave the current repeat context, restoring the parent.

Trait Implementations§

Source§

impl Default for FormspecEnvironment

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Environment for FormspecEnvironment

Source§

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

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], ) -> TypeValue

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

fn mip_valid(&self, path: &[String]) -> TypeValue

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

fn mip_relevant(&self, path: &[String]) -> TypeValue

relevant($path) — default true.
Source§

fn mip_readonly(&self, path: &[String]) -> TypeValue

readonly($path) — default false.
Source§

fn mip_required(&self, path: &[String]) -> TypeValue

required($path) — default false.
Source§

fn repeat_prev(&self) -> TypeValue

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

fn repeat_next(&self) -> TypeValue

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

fn repeat_parent(&self) -> TypeValue

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

fn current_date(&self) -> Result<TypeDate, 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<TypeDate, 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 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) -> TypeValue

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.