pub struct Context { /* private fields */ }Expand description
structure that contains all the data at the count level, saves the variables, tokens, functions and keys Use example :
use processor::context::Context;
let mut context = Context::new();
context.push_key("key".to_owned(), |token, prog| {
prog.exec(&token);
processor::values::Values::Null
});Implementations§
Source§impl Context
impl Context
Sourcepub fn token_index(&self, tok: &str) -> usize
pub fn token_index(&self, tok: &str) -> usize
Localize the index in the list of tokens of the token
§PANICS
Return a panic if the token is not registered on the context
Sourcepub fn push_token(&mut self, tok: Box<dyn Token>)
pub fn push_token(&mut self, tok: Box<dyn Token>)
Register a new token in te context
Sourcepub fn push_memory(&mut self, key: &str, tok: Values)
pub fn push_memory(&mut self, key: &str, tok: Values)
Push a new data on the memory
Sourcepub fn push_key(
&mut self,
key: String,
tok: impl Fn(String, &mut ProgramBlock) -> Values + 'static,
)
pub fn push_key( &mut self, key: String, tok: impl Fn(String, &mut ProgramBlock) -> Values + 'static, )
Register a new key
Sourcepub fn push_function(
&mut self,
name: String,
func: impl Fn(String, &mut ProgramBlock) -> Values + 'static,
)
pub fn push_function( &mut self, name: String, func: impl Fn(String, &mut ProgramBlock) -> Values + 'static, )
Add a new function
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