pub struct Evaluator { /* private fields */ }Expand description
Evaluates dynamic values against a set of catalogs.
Implementations§
Source§impl Evaluator
impl Evaluator
Sourcepub fn new(catalogs: impl IntoIterator<Item = Catalog>) -> Self
pub fn new(catalogs: impl IntoIterator<Item = Catalog>) -> Self
An evaluator over the catalogs a surface may use.
Sourcepub fn register(
&mut self,
name: impl Into<String>,
def: FunctionDef,
function: LocalFunction,
)
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.
Sourcepub fn evaluate(
&self,
value: &Value,
scope: &Scope<'_>,
) -> Result<Value, EvalError>
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.
Trait Implementations§
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 Evaluatorwhere
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 Evaluatorwhere
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 Evaluatorwhere
*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 Evaluatorwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Catalog>: UnsafeUnpin,
PhantomData<(String, FunctionDef, Arc<dyn Fn(&Map<String, Value>, &Scope<'_>) -> Result<Value, String> + Sync + Send>)>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more