Skip to main content

Evaluator

Struct Evaluator 

Source
pub struct Evaluator { /* private fields */ }
Expand description

Evaluates dynamic values against a set of catalogs.

Implementations§

Source§

impl Evaluator

Source

pub fn new(catalogs: impl IntoIterator<Item = Catalog>) -> Self

An evaluator over the catalogs a surface may use.

Source

pub fn register( &mut self, name: impl Into<String>, def: FunctionDef, function: LocalFunction, )

Implement a function on the renderer: def says who may call it and whether it needs a gesture, as a catalog entry would. A registered function can be called from any of the evaluator’s catalogs.

Source

pub fn basic() -> Self

An evaluator over the basic catalog alone.

Source

pub fn evaluate( &self, value: &Value, scope: &Scope<'_>, ) -> Result<Value, EvalError>

Resolve a dynamic value: a {"@path": ...} reads the data model (absent is null), a {"@call": ...} calls the function, an array resolves element by element, and any other object is a literal (its @@ keys unescaped to @). A literal object with a single-@ key is refused, as the specification reserves that namespace.

Source

pub fn call( &self, call: &Map<String, Value>, scope: &Scope<'_>, ) -> Result<Value, EvalError>

Call a function: {"@call": name, "catalogId"?: ..., "args"?: {...}}.

Trait Implementations§

Source§

impl Clone for Evaluator

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 Debug for Evaluator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Evaluator

§

impl !UnwindSafe for Evaluator

§

impl Forget for Evaluator

§

impl Freeze for Evaluator

§

impl Move for Evaluator

§

impl Send for Evaluator
where RawVecInner: Send, RawTable<usize>: Send, NodeRef<Owned, String, ComponentDef, LeafOrInternal>: Send, BoxRaw<(String, ComponentDef)>: Send, NodeRef<Owned, String, FunctionDef, LeafOrInternal>: Send, BoxRaw<(String, FunctionDef)>: Send, Arc<dyn Fn(&Map<String, Value>, &Scope<'_>) -> Result<Value, String> + Sync + Send>: Send,

§

impl Sync for Evaluator
where RawVecInner: Sync, RawTable<usize>: Sync, NodeRef<Owned, String, ComponentDef, LeafOrInternal>: Sync, BoxRaw<(String, ComponentDef)>: Sync, NodeRef<Owned, String, FunctionDef, LeafOrInternal>: Sync, BoxRaw<(String, FunctionDef)>: Sync, Arc<dyn Fn(&Map<String, Value>, &Scope<'_>) -> Result<Value, String> + Sync + Send>: Sync,

§

impl Unpin for Evaluator
where *const u8 is !null: Unpin, *const LeafNode<String, ComponentDef> is !null: Unpin, Box<(String, ComponentDef)>: Unpin, *const LeafNode<String, FunctionDef> is !null: Unpin, Box<(String, FunctionDef)>: Unpin, Arc<dyn Fn(&Map<String, Value>, &Scope<'_>) -> Result<Value, String> + Sync + Send>: Unpin,

§

impl UnsafeUnpin for Evaluator

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.