[][src]Trait evalexpr::Context

pub trait Context {
    fn get_value(&self, identifier: &str) -> Option<&Value>;
fn get_function(&self, identifier: &str) -> Option<&Function>; fn set_value(
        &mut self,
        _identifier: String,
        _value: Value
    ) -> EvalexprResult<()> { ... }
fn set_function(
        &mut self,
        _identifier: String,
        _function: Function
    ) -> EvalexprResult<()> { ... } }

A mutable context for an expression tree.

A context defines methods to retrieve values and functions for literals in an expression tree. In addition, it also allows the manipulation of values and functions. This crate implements two basic variants, the EmptyContext, that returns None for each identifier and cannot be manipulated, and the HashMapContext, that stores its mappings in hash maps. The HashMapContext is type-safe and returns an error if the user tries to assign a value of a different type than before to an identifier.

Required methods

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

Returns the value that is linked to the given identifier.

fn get_function(&self, identifier: &str) -> Option<&Function>

Returns the function that is linked to the given identifier.

Loading content...

Provided methods

fn set_value(
    &mut self,
    _identifier: String,
    _value: Value
) -> EvalexprResult<()>

Links the given value to the given identifier.

fn set_function(
    &mut self,
    _identifier: String,
    _function: Function
) -> EvalexprResult<()>

Links the given function to the given identifier.

Loading content...

Implementors

impl Context for EmptyContext[src]

fn set_value(
    &mut self,
    _identifier: String,
    _value: Value
) -> EvalexprResult<()>
[src]

fn set_function(
    &mut self,
    _identifier: String,
    _function: Function
) -> EvalexprResult<()>
[src]

impl Context for HashMapContext[src]

Loading content...