pub struct Context { /* private fields */ }Expand description
Context that is passed while evaluating an AST by an Evaluator.
Contains all variables and states that can be shared between functions during evaluations. Functions should be free to store any state that will be shared between function invocations.
Variables are stored in a map, keys are Strings and values are also Strings. State is stored in a heterogeneous container, which means that is accepts any struct. Structs in this store are identifier by their TypeId.
Implementations§
Source§impl Context
impl Context
pub fn empty() -> Context
pub fn with_variables(variables: HashMap<String, String>) -> Context
pub fn set_variable(&mut self, name: &str, value: &str)
pub fn get_variable(&self, name: &str) -> Option<&String>
pub fn save_state<T: Any>(&mut self, state: T)
pub fn get_state<T: Any>(&self) -> Option<&T>
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
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