Trait Context

Source
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§

Source

type NumericTypes: EvalexprNumericTypes

The numeric types used for evaluation.

Required Methods§

Source

fn get_value(&self, identifier: &str) -> Option<&Value<Self::NumericTypes>>

Returns the value that is linked to the given identifier.

Source

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.

Source

fn are_builtin_functions_disabled(&self) -> bool

Checks if builtin functions are disabled.

Source

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.

Implementors§

Source§

impl<NumericTypes: EvalexprNumericTypes> Context for EmptyContext<NumericTypes>

Source§

type NumericTypes = NumericTypes

Source§

impl<NumericTypes: EvalexprNumericTypes> Context for EmptyContextWithBuiltinFunctions<NumericTypes>

Source§

type NumericTypes = NumericTypes

Source§

impl<NumericTypes: EvalexprNumericTypes> Context for HashMapContext<NumericTypes>

Source§

type NumericTypes = NumericTypes