pub struct ExprEngine { /* private fields */ }Expand description
Compiles and evaluates the JSONLogic a definition is written in.
Cheap to clone: a clone shares the datalogic engine, the operator table and the secrets.
Implementations§
Source§impl ExprEngine
impl ExprEngine
Sourcepub fn interpolated(&self, raw: &Value) -> Result<Interpolated, Vec<Issue>>
pub fn interpolated(&self, raw: &Value) -> Result<Interpolated, Vec<Issue>>
Compiles a document of var holes in otherwise literal data.
Advisories and Defects (a payload hole, an operator left as data) are
dropped on Ok; a config field compiled through ConfigField is the
way to get them.
§Errors
Every issue, when any is Rejected.
Source§impl ExprEngine
impl ExprEngine
Sourcepub fn builder() -> ExprEngineBuilder
pub fn builder() -> ExprEngineBuilder
Starts a builder.
Sourcepub fn operators(&self) -> &[Operator]
pub fn operators(&self) -> &[Operator]
Every operator this engine evaluates: the datalogic built-ins its
selected families enable, then the host’s operators in registration
order, then secret.
Sourcepub fn compile<T: FromValue>(&self, raw: &Value) -> Result<Expr<T>>
pub fn compile<T: FromValue>(&self, raw: &Value) -> Result<Expr<T>>
Compiles raw. An expression that reads nothing is evaluated once, here,
and kept as its T.
§Errors
ErrorKind::Compile when datalogic refuses the expression;
ErrorKind::Eval when evaluating a constant at fold time fails;
ErrorKind::Config when a folded constant is not a T.
Sourcepub fn eval<'e, 'r, T: FromValue>(
&self,
expr: &'e Expr<T>,
root: impl EvalRoot<'r>,
) -> Result<Evaluated<T::Out<'e>>>
pub fn eval<'e, 'r, T: FromValue>( &self, expr: &'e Expr<T>, root: impl EvalRoot<'r>, ) -> Result<Evaluated<T::Out<'e>>>
Evaluates expr against root, an object holding the three context
roots, as an OwnedDataValue or a serde_json::Value
(EvalRoot). A folded constant is lent from expr and takes no
arena.
§Errors
ErrorKind::Budget when the operation ceiling is exceeded;
ErrorKind::Eval for any other failure, including a result that is
not a T.