pub struct ResolveContext<'a> {
pub data: &'a Value,
pub scope: &'a str,
pub strings: Option<&'a StringTable>,
pub overlay: Option<(&'a str, &'a Value)>,
pub item: Option<&'a Value>,
pub view: Option<&'a CatalogView>,
pub formatter: Option<&'a dyn Formatter>,
pub now: Option<f64>,
}Expand description
What resolve_value needs.
Fields§
§data: &'a Value§scope: &'a strThe template item’s pointer, for relative paths.
strings: Option<&'a StringTable>The surface’s built-in string table: a $string.<id> value resolves
through it (None = left as written).
overlay: Option<(&'a str, &'a Value)>A value standing in for a pointer prefix (a literal Table row is the
data scope of its slot cells): (prefix, value).
item: Option<&'a Value>A LITERAL item that is not in the data model (a Table row of literal
rows, the TS DataScope.item): relative paths read inside it,
absolute ones still the data, and a relative set writes nothing.
view: Option<&'a CatalogView>The catalog whose prop schemas decide which props are DATA
(bind_tree); None = the core catalog.
formatter: Option<&'a dyn Formatter>Round 2: the surface’s formatter (SurfaceSettings.locale + the
host’s zone); the format functions run through it. None = the
English fallback (crate::format::ENGLISH).
now: Option<f64>The clock (epoch ms) formatRelativeTime reads without a now
argument; None = the wall clock.
Implementations§
Source§impl<'a> ResolveContext<'a>
impl<'a> ResolveContext<'a>
pub fn new(data: &'a Value, scope: &'a str) -> ResolveContext<'a>
Sourcepub fn with_formatter(self, formatter: &'a dyn Formatter) -> ResolveContext<'a>
pub fn with_formatter(self, formatter: &'a dyn Formatter) -> ResolveContext<'a>
Format through the surface’s formatter (see ResolveContext::formatter).
Sourcepub fn with_now(self, now_ms: f64) -> ResolveContext<'a>
pub fn with_now(self, now_ms: f64) -> ResolveContext<'a>
A fixed clock for formatRelativeTime (fixtures, a host re-binding
once a minute).
Sourcepub fn with_item(self, item: &'a Value) -> ResolveContext<'a>
pub fn with_item(self, item: &'a Value) -> ResolveContext<'a>
Relative paths read inside item (see ResolveContext::item).
Sourcepub fn with_view(self, view: &'a CatalogView) -> ResolveContext<'a>
pub fn with_view(self, view: &'a CatalogView) -> ResolveContext<'a>
Bind against an extended catalog (its components’ prop schemas).
Sourcepub fn read_path(&self, path: &str) -> Option<&'a Value>
pub fn read_path(&self, path: &str) -> Option<&'a Value>
The value a binding path names: inside the literal item for a relative path under an item scope, else at its absolute pointer.