pub trait Context {
type NumericTypes: EvalexprNumericTypes;
// Required methods
fn get_value(&self, identifier: &str) -> Option<&Value<Self::NumericTypes>>;
fn call_function(
&self,
identifier: &str,
argument: &Value<Self::NumericTypes>,
) -> EvalexprResultValue<Self::NumericTypes>;
fn are_builtin_functions_disabled(&self) -> bool;
fn set_builtin_functions_disabled(
&mut self,
disabled: bool,
) -> EvalexprResult<(), Self::NumericTypes>;
}
Expand description
An immutable context.
Required Associated Types§
Sourcetype NumericTypes: EvalexprNumericTypes
type NumericTypes: EvalexprNumericTypes
The numeric types used for evaluation.
Required Methods§
Sourcefn get_value(&self, identifier: &str) -> Option<&Value<Self::NumericTypes>>
fn get_value(&self, identifier: &str) -> Option<&Value<Self::NumericTypes>>
Returns the value that is linked to the given identifier.
Sourcefn call_function(
&self,
identifier: &str,
argument: &Value<Self::NumericTypes>,
) -> EvalexprResultValue<Self::NumericTypes>
fn call_function( &self, identifier: &str, argument: &Value<Self::NumericTypes>, ) -> EvalexprResultValue<Self::NumericTypes>
Calls the function that is linked to the given identifier with the given argument.
If no function with the given identifier is found, this method returns EvalexprError::FunctionIdentifierNotFound
.
Sourcefn are_builtin_functions_disabled(&self) -> bool
fn are_builtin_functions_disabled(&self) -> bool
Checks if builtin functions are disabled.
Sourcefn set_builtin_functions_disabled(
&mut self,
disabled: bool,
) -> EvalexprResult<(), Self::NumericTypes>
fn set_builtin_functions_disabled( &mut self, disabled: bool, ) -> EvalexprResult<(), Self::NumericTypes>
Disables builtin functions if disabled
is true
, and enables them otherwise.
If the context does not support enabling or disabling builtin functions, an error is returned.