pub struct Context {
pub globals: BTreeMap<String, Box<dyn Any>>,
}Expand description
Virtual machine context
Fields§
§globals: BTreeMap<String, Box<dyn Any>>The global variables queryable by name
Implementations§
Source§impl Context
impl Context
Sourcepub fn set_global<K: ToString, V: Any>(&mut self, key: K, value: V)
pub fn set_global<K: ToString, V: Any>(&mut self, key: K, value: V)
Set a global variable
Sourcepub fn replace_global<K: ToString, V: Any, R: Any>(
&mut self,
key: K,
value: V,
) -> Result<Option<Box<R>>, Trap>
pub fn replace_global<K: ToString, V: Any, R: Any>( &mut self, key: K, value: V, ) -> Result<Option<Box<R>>, Trap>
This does the same thing as set_global but attempts to return the variable which was replaced
Sourcepub fn get_global<K: AsRef<str>, V: Any>(
&self,
key: K,
) -> Result<Option<&V>, Trap>
pub fn get_global<K: AsRef<str>, V: Any>( &self, key: K, ) -> Result<Option<&V>, Trap>
Get a global variable
Sourcepub fn get_global_mut<K: AsRef<str>, V: Any>(
&mut self,
key: K,
) -> Result<Option<&mut V>, Trap>
pub fn get_global_mut<K: AsRef<str>, V: Any>( &mut self, key: K, ) -> Result<Option<&mut V>, Trap>
Get a mutable reference to a global variable
Sourcepub fn delete_global<K: AsRef<str>>(&mut self, key: K)
pub fn delete_global<K: AsRef<str>>(&mut self, key: K)
Delete a global variable
Trait Implementations§
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