[][src]Struct ogma_libs::vm::Context

pub struct Context {
    pub globals: BTreeMap<String, Box<dyn Any>>,
}

Virtual machine context

Fields

globals: BTreeMap<String, Box<dyn Any>>

The global variables queryable by name

Implementations

impl Context[src]

pub fn new() -> Self[src]

Create an empty context

pub fn set_global<K: ToString, V: Any>(&mut self, key: K, value: V)[src]

Set a global variable

pub fn replace_global<K: ToString, V: Any, R: Any>(
    &mut self,
    key: K,
    value: V
) -> Result<Option<Box<R>>, Trap>
[src]

This does the same thing as set_global but attempts to return the variable which was replaced

pub fn get_global<K: AsRef<str>, V: Any>(
    &self,
    key: K
) -> Result<Option<&V>, Trap>
[src]

Get a global variable

pub fn get_global_mut<K: AsRef<str>, V: Any>(
    &mut self,
    key: K
) -> Result<Option<&mut V>, Trap>
[src]

Get a mutable reference to a global variable

pub fn delete_global<K: AsRef<str>>(&mut self, key: K)[src]

Delete a global variable

pub fn remove_global<K: AsRef<str>, R: Any>(
    &mut self,
    key: K
) -> Result<Option<Box<R>>, Trap>
[src]

Does the same thing as delete_global but attempts to return the removed variable

Trait Implementations

impl Default for Context[src]

Auto Trait Implementations

impl !RefUnwindSafe for Context

impl !Send for Context

impl !Sync for Context

impl Unpin for Context

impl !UnwindSafe for Context

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.