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§
Sourcefn define_env(&mut self, key: &str, value: ScriptingValue) -> Result<(), Error>
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.
Sourcefn get_env(&self, key: &str) -> Result<ScriptingValue, Error>
fn get_env(&self, key: &str) -> Result<ScriptingValue, Error>
Returns the ScriptingValue stored behind key.
§Errors
Error::EnvVarNotDefined if the variable does not exist