Skip to main content

ResolveContext

Struct ResolveContext 

Source
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 str

The 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>

Source

pub fn new(data: &'a Value, scope: &'a str) -> ResolveContext<'a>

Source

pub fn with_formatter(self, formatter: &'a dyn Formatter) -> ResolveContext<'a>

Format through the surface’s formatter (see ResolveContext::formatter).

Source

pub fn with_now(self, now_ms: f64) -> ResolveContext<'a>

A fixed clock for formatRelativeTime (fixtures, a host re-binding once a minute).

Source

pub fn formatter(&self) -> &'a dyn Formatter

The formatter in effect.

Source

pub fn with_item(self, item: &'a Value) -> ResolveContext<'a>

Relative paths read inside item (see ResolveContext::item).

Source

pub fn with_view(self, view: &'a CatalogView) -> ResolveContext<'a>

Bind against an extended catalog (its components’ prop schemas).

Source

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.

Source

pub fn with_strings(self, strings: &'a StringTable) -> ResolveContext<'a>

Source

pub fn with_overlay( self, prefix: &'a str, value: &'a Value, ) -> ResolveContext<'a>

Source

pub fn read(&self, pointer: &str) -> Option<&'a Value>

The value at an absolute pointer (through the overlay when it names the overlay’s prefix).

Trait Implementations§

Source§

impl<'a> Clone for ResolveContext<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ResolveContext<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ResolveContext<'a>

§

impl<'a> !UnwindSafe for ResolveContext<'a>

§

impl<'a> Freeze for ResolveContext<'a>

§

impl<'a> Send for ResolveContext<'a>

§

impl<'a> Sync for ResolveContext<'a>

§

impl<'a> Unpin for ResolveContext<'a>

§

impl<'a> UnsafeUnpin for ResolveContext<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.