Run code in virtual machines (sandboxes)
This crate provides an abstract API for the Rust programming language to allow executing scripting language code snippets in a sandbox.
The scripting language (or VM which executes code written in that scripting language) is not specified by this crate. Instead, other crates may use this crate to provide a scripting-language-independent interface to execute certain functions or provide callbacks from the VM to Rust.
Central trait is a
Machine, which is capable to compile certain code
into a function (see trait
Compile for compiling code into functions,
and see associated type
Machine::Function and trait
executing these functions).
Passing values from Rust to the VM or from the VM to Rust is done through a
“datum” type that is specific to each particular VM used (see associated
Machine::Datum). Some VMs may support creating closures in Rust
which can then be converted into a “datum” and passed to the VM (see trait
As different VMs may have “datum” types with different features (e.g. some
scripting languages might support integers while others only know strings,
Machine::Datum can implement different traits in the
which determine which functionality is supported
types::MaybeString if a datum can be a string).
pub use errors::*;
- Error traits and error kinds
- Prelude that (currently) re-exports everything
- Unnameable traits to be included via wildcard syntax
- Traits to be implemented by
Machine::Datumto support specific types
- Ability of
Machines to call provided callbacks
- Ability of
Machines to compile provided code (of a certain type, e.g.
- Basic interface of function that runs in a
Machines that support global variables
- Ability to load language-independent modules into a
- Virtual machine to execute code (with inner mutability)