pub trait EvalRoot<'r>: Sealed<'r> { }Expand description
A root ExprEngine::eval evaluates against: an object holding the
three context roots, as an OwnedDataValue or as a
serde_json::Value.
Either is viewed in place, its strings and keys borrowed and only its
arrays’ and objects’ spines built, so a host that holds its context as
JSON evaluates it without converting it first, and gets what the same
context as an OwnedDataValue gives. Sealed: the two are the
implementations.
use dataflow_rs::datavalue::OwnedDataValue;
use dataflow_rs::expr::ExprEngine;
use dataflow_rs::Expr;
use serde_json::json;
let exprs = ExprEngine::default();
let limit: Expr<u64> = exprs.compile(&json!({"*": [{"var": "data.n"}, 2]})).unwrap();
let context = json!({"data": {"n": 21}, "metadata": {}, "temp_data": {}});
assert_eq!(exprs.eval(&limit, &context).unwrap().value, 42);
let owned = OwnedDataValue::from(&context);
assert_eq!(exprs.eval(&limit, &owned).unwrap().value, 42);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".