pub struct EvalBuilder<'a> { /* private fields */ }Expand description
A builder bound to a ParsedExpression that defers choosing symbol
tables until evaluate is called.
Obtained from parsed.with_*(...) on a ParsedExpression. Every
with_* method is chainable. The terminal evaluate(&symtabs) and
evaluate_with_metrics(&symtabs) methods build an internal evaluator
from the captured configuration and run it.
use openjd_expr::{ExprValue, ParsedExpression, PathFormat, SymbolTable};
let parsed = ParsedExpression::new("Param.Frame * 2").unwrap();
let mut st = SymbolTable::new();
st.set("Param.Frame", 5).unwrap();
let value = parsed
.with_path_format(PathFormat::Posix)
.with_memory_limit(50_000_000)
.evaluate(&[&st])
.unwrap();
assert_eq!(value, ExprValue::Int(10));Implementations§
Source§impl<'a> EvalBuilder<'a>
impl<'a> EvalBuilder<'a>
Sourcepub fn with_library(self, library: &'a FunctionLibrary) -> Self
pub fn with_library(self, library: &'a FunctionLibrary) -> Self
Use the given function library instead of the default one.
Sourcepub fn with_memory_limit(self, limit: usize) -> Self
pub fn with_memory_limit(self, limit: usize) -> Self
Cap evaluation memory (bytes). Default: DEFAULT_MEMORY_LIMIT.
Sourcepub fn with_operation_limit(self, limit: usize) -> Self
pub fn with_operation_limit(self, limit: usize) -> Self
Cap evaluation operations. Default: DEFAULT_OPERATION_LIMIT.
Sourcepub fn with_path_format(self, format: PathFormat) -> Self
pub fn with_path_format(self, format: PathFormat) -> Self
Normalize path values according to format. Default: host-native.
Sourcepub fn with_target_type(self, target_type: &'a ExprType) -> Self
pub fn with_target_type(self, target_type: &'a ExprType) -> Self
Coerce the final value toward target_type. Default: no coercion.
Sourcepub fn evaluate(
self,
symtabs: &'a [&'a SymbolTable],
) -> Result<ExprValue, ExpressionError>
pub fn evaluate( self, symtabs: &'a [&'a SymbolTable], ) -> Result<ExprValue, ExpressionError>
Evaluate against the supplied symbol tables and return the resulting value.
Sourcepub fn evaluate_with_metrics(
self,
symtabs: &'a [&'a SymbolTable],
) -> Result<EvalResult, ExpressionError>
pub fn evaluate_with_metrics( self, symtabs: &'a [&'a SymbolTable], ) -> Result<EvalResult, ExpressionError>
Evaluate and return the value alongside resource-usage metrics.
Auto Trait Implementations§
impl<'a> Freeze for EvalBuilder<'a>
impl<'a> !RefUnwindSafe for EvalBuilder<'a>
impl<'a> Send for EvalBuilder<'a>
impl<'a> Sync for EvalBuilder<'a>
impl<'a> Unpin for EvalBuilder<'a>
impl<'a> UnsafeUnpin for EvalBuilder<'a>
impl<'a> !UnwindSafe for EvalBuilder<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more