pub struct Manager { /* private fields */ }
Expand description
The Virtual Machine Manager handles WASM runtime lifecycle and module execution.
This struct encapsulates the WASM runtime and provides high-level operations for executing WASM modules with proper I/O redirection and resource management.
Implementations§
Source§impl Manager
impl Manager
Sourcepub fn new(registrables: &[&dyn Registrable]) -> Result<Self>
pub fn new(registrables: &[&dyn Registrable]) -> Result<Self>
Create a new Virtual Machine Manager with the given registrable host functions.
This function initializes the WASM runtime, registers all provided host functions, and pre-loads any modules that the registrables provide.
§Arguments
Registrables
- Array of objects implementing host functions and optionally providing WASM modules
§Returns
A new Manager instance or an error if initialization fails
§Errors
Returns an error if:
- Runtime initialization fails
- Host function registration fails
- Module loading fails
Sourcepub async fn execute(
&'static self,
buffer: Vec<u8>,
stack_size: usize,
standard_in: UniqueFileIdentifier,
standard_out: UniqueFileIdentifier,
standard_error: UniqueFileIdentifier,
) -> Result<Vec<WasmValue>>
pub async fn execute( &'static self, buffer: Vec<u8>, stack_size: usize, standard_in: UniqueFileIdentifier, standard_out: UniqueFileIdentifier, standard_error: UniqueFileIdentifier, ) -> Result<Vec<WasmValue>>
Execute a WASM module with the specified I/O configuration.
This is the main entry point for executing WASM modules. It creates a new module instance, sets up the execution environment with proper I/O redirection, and calls the module’s main function.
§Arguments
Buffer
- The WASM module bytecode to executeStack_size
- Stack size in bytes for the WASM instanceStandard_in
- File identifier for standard inputStandard_out
- File identifier for standard outputStandard_error
- File identifier for standard error
§Returns
The return values from the WASM module’s main function
§Errors
Returns an error if module loading, instantiation, or execution fails