pub struct Evaluator { /* private fields */ }Expand description
High-performance zero-copy evaluator with dual-context support
§Design Principles
- Zero-copy: All data access via references, no cloning
- Dual-context: Separate user_data and internal_context for scoped variables
- Recursive: Clean recursive evaluation with depth tracking
§Context Resolution
- Variables ($var) lookup order: internal_context → user_data
- Internal context holds: $iteration, $threshold, $loopIteration, etc.
Implementations§
Source§impl Evaluator
impl Evaluator
pub fn new() -> Self
pub fn with_config(self, config: RLogicConfig) -> Self
Sourcepub fn evaluate(
&self,
logic: &CompiledLogic,
data: &Value,
) -> Result<Value, String>
pub fn evaluate( &self, logic: &CompiledLogic, data: &Value, ) -> Result<Value, String>
Public API: Evaluate compiled logic with user data only Uses fast path for simple cases to avoid recursion overhead
Sourcepub fn evaluate_with_internal_context(
&self,
logic: &CompiledLogic,
user_data: &Value,
internal_context: &Value,
) -> Result<Value, String>
pub fn evaluate_with_internal_context( &self, logic: &CompiledLogic, user_data: &Value, internal_context: &Value, ) -> Result<Value, String>
Evaluate with internal context (for scoped variables)
§Arguments
logic- The compiled logic expression to evaluateuser_data- User’s data (primary lookup source)internal_context- Internal variables (e.g., $iteration, $loopIteration)
§Zero-Copy Guarantee
This method uses only references and never clones the data contexts.
Internal variables are looked up first in internal_context, then fall back to user_data.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Evaluator
impl RefUnwindSafe for Evaluator
impl Send for Evaluator
impl Sync for Evaluator
impl Unpin for Evaluator
impl UnwindSafe for Evaluator
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