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
@variableNamewhen no host catalog is active - Mapping-style context via host-specific
Environmentimplementations - Locale via
locale()andpluralCategory() - 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
impl FormspecEnvironment
Sourcepub fn set_field(&mut self, path: &str, value: TypeValue)
pub fn set_field(&mut self, path: &str, value: TypeValue)
Set a field value by dotted path (e.g., “address.city”).
Sourcepub fn set_instance(&mut self, name: &str, value: TypeValue)
pub fn set_instance(&mut self, name: &str, value: TypeValue)
Set a named instance.
Sourcepub fn set_variable(&mut self, name: &str, value: TypeValue)
pub fn set_variable(&mut self, name: &str, value: TypeValue)
Set a variable value.
Sourcepub fn set_locale(&mut self, code: &str)
pub fn set_locale(&mut self, code: &str)
Set the active locale code (BCP 47).
Sourcepub fn set_date_format(&mut self, style: &str, pattern: &str)
pub fn set_date_format(&mut self, style: &str, pattern: &str)
Set the pattern a formatDate style renders with (Locale formats.date.<style>).
Sourcepub fn set_now_from_iso(&mut self, iso: &str)
pub fn set_now_from_iso(&mut self, iso: &str)
Set the current runtime datetime from an ISO string.
Sourcepub fn push_repeat(
&mut self,
current: TypeValue,
index: usize,
count: usize,
collection: Vec<TypeValue>,
)
pub fn push_repeat( &mut self, current: TypeValue, index: usize, count: usize, collection: Vec<TypeValue>, )
Enter a repeat context.
Sourcepub fn pop_repeat(&mut self)
pub fn pop_repeat(&mut self)
Leave the current repeat context, restoring the parent.
Trait Implementations§
Source§impl Default for FormspecEnvironment
impl Default for FormspecEnvironment
Source§impl Environment for FormspecEnvironment
impl Environment for FormspecEnvironment
Source§fn resolve_field(&self, segments: &[String]) -> TypeValue
fn resolve_field(&self, segments: &[String]) -> TypeValue
$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
fn resolve_context( &self, name: &str, arg: Option<&str>, tail: &[String], ) -> TypeValue
@name, @name('arg'), @name.tail.Source§fn mip_valid(&self, path: &[String]) -> TypeValue
fn mip_valid(&self, path: &[String]) -> TypeValue
valid($path) — default true when not overridden.Source§fn mip_relevant(&self, path: &[String]) -> TypeValue
fn mip_relevant(&self, path: &[String]) -> TypeValue
relevant($path) — default true.Source§fn mip_readonly(&self, path: &[String]) -> TypeValue
fn mip_readonly(&self, path: &[String]) -> TypeValue
readonly($path) — default false.Source§fn mip_required(&self, path: &[String]) -> TypeValue
fn mip_required(&self, path: &[String]) -> TypeValue
required($path) — default false.Source§fn repeat_prev(&self) -> TypeValue
fn repeat_prev(&self) -> TypeValue
prev() in repeat scope — default null.Source§fn repeat_next(&self) -> TypeValue
fn repeat_next(&self) -> TypeValue
next() in repeat scope — default null.Source§fn repeat_parent(&self) -> TypeValue
fn repeat_parent(&self) -> TypeValue
parent() in repeat scope — default null.Source§fn current_date(&self) -> Result<TypeDate, MissingTimezoneContextError>
fn current_date(&self) -> Result<TypeDate, MissingTimezoneContextError>
today() per ADR 0069 D-6 — hosts MUST configure a
timezone-equivalent clock or return MissingTimezoneContextError. Read moreSource§fn current_datetime(&self) -> Result<TypeDate, MissingTimezoneContextError>
fn current_datetime(&self) -> Result<TypeDate, 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 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) -> TypeValue
fn runtime_meta(&self, key: &str) -> TypeValue
runtimeMeta(key) — default null.