Environment

Trait Environment 

Source
pub trait Environment: Send + Sync {
    // Required methods
    fn define_env(
        &mut self,
        key: &str,
        value: ScriptingValue,
    ) -> Result<(), Error>;
    fn get_env(&self, key: &str) -> Result<ScriptingValue, Error>;
    fn set_env(&mut self, key: &str, value: ScriptingValue) -> Result<(), Error>;
}
Expand description

The trait for providing an Environment to a VM that stores the ScriptingValues persistent and external available.

An environment must be a key-value-store that can store ScriptingValues.

Required Methods§

Source

fn define_env(&mut self, key: &str, value: ScriptingValue) -> Result<(), Error>

Creates or updates the ScriptingValue behind key. Value will be created if it does not already exist.

§Errors

Error::EnvVarWrongType if the variable exists with a different type.

Source

fn get_env(&self, key: &str) -> Result<ScriptingValue, Error>

Returns the ScriptingValue stored behind key.

§Errors

Error::EnvVarNotDefined if the variable does not exist

Source

fn set_env(&mut self, key: &str, value: ScriptingValue) -> Result<(), Error>

Set the variable with key to value.

§Errors

if variable does not exist.

Implementors§