Skip to main content

EngineBuilder

Struct EngineBuilder 

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

Builder for Engine. Construct via Engine::builder.

use datalogic_rs::Engine;

let engine = Engine::builder().build();

§Defaults

Engine::builder().build() produces the same engine as Engine::new / Engine::default:

Implementations§

Source§

impl EngineBuilder

Source

pub fn new() -> Self

Fresh builder with default config and no custom operators.

Source

pub fn with_config(self, config: EvaluationConfig) -> Self

Set the evaluation config.

Source

pub fn with_templating(self, on: bool) -> Self

Toggle templating mode (multi-key objects compile to output-shaping templates; unknown operator keys pass through verbatim). Only effective when the crate is built with feature = "templating".

Source

pub fn with_constant_folding(self, on: bool) -> Self

Toggle the compile-time constant-folding pass. Default: true (folding enabled). Pass false when every operator must survive in the compiled tree — debuggers, alternate evaluators, or any caller that walks the compiled structure and would be surprised to see a {"+": [1, 2]} collapsed to a 3 literal.

The trace surface (crate::Engine::trace) always disables folding internally regardless of this setting, since traces would otherwise lose the folded operators as steps.

Source

pub fn add_operator<T>(self, name: impl Into<String>, operator: T) -> Self
where T: CustomOperator + 'static,

Register a CustomOperator under name. Multiple calls with the same name overwrite the prior registration.

Accepts both typed operators (T: CustomOperator + 'static) and pre-boxed trait objects (Box<dyn CustomOperator>) — the bare Box<dyn CustomOperator> itself implements CustomOperator (delegating to the inner), so a single entry point covers both shapes:

builder
    .add_operator("typed", MyOp)                            // typed
    .add_operator("dyn", boxed_op_from_registry as Box<_>)  // pre-boxed

Operator registration is builder-only; once Self::build hands you an Engine, its operator set is frozen.

Built-ins always win. If name collides with a built-in JSONLogic operator (+, if, var, map, …), the built-in is dispatched and the registered custom op is never reached. To extend the operator set, choose a name that doesn’t parse as a built-in.

Source

pub fn build(self) -> Engine

Finalise the builder into an immutable Engine engine.

Trait Implementations§

Source§

impl Default for EngineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.