pub struct WasmSandbox { /* private fields */ }Expand description
A sandbox with just the Wasm engine loaded into memory. WasmSandboxes
are not yet ready to execute guest functions.
Before you can call guest functions, you must call the load_module
function to load a Wasm module into memory. That function will return a
LoadedWasmSandbox able to execute code in the loaded Wasm Module.
Implementations§
Source§impl WasmSandbox
impl WasmSandbox
Sourcepub fn load_module(self, file: impl AsRef<Path>) -> Result<LoadedWasmSandbox>
pub fn load_module(self, file: impl AsRef<Path>) -> Result<LoadedWasmSandbox>
Load a Wasm module at the given path into the sandbox and return a LoadedWasmSandbox
able to execute code in the loaded Wasm Module.
Before you can call guest functions in the sandbox, you must call this function and use the returned value to call guest functions.
Sourcepub fn load_from_snapshot(
self,
snapshot: Arc<Snapshot>,
) -> Result<LoadedWasmSandbox>
pub fn load_from_snapshot( self, snapshot: Arc<Snapshot>, ) -> Result<LoadedWasmSandbox>
Load a Wasm module by restoring a Hyperlight snapshot taken
from a LoadedWasmSandbox.
Sourcepub unsafe fn load_module_by_mapping(
self,
base: *mut c_void,
len: usize,
) -> Result<LoadedWasmSandbox>
pub unsafe fn load_module_by_mapping( self, base: *mut c_void, len: usize, ) -> Result<LoadedWasmSandbox>
Load a Wasm module that is currently present in a buffer in host memory, by mapping the host memory directly into the sandbox.
Depending on the host platform, there are likely alignment requirements of at least one page for base and len
§Safety
It is the caller’s responsibility to ensure that the host side of the region remains intact and is not written to until the produced LoadedWasmSandbox is discarded or devolved.
Sourcepub fn load_module_from_buffer(self, buffer: &[u8]) -> Result<LoadedWasmSandbox>
pub fn load_module_from_buffer(self, buffer: &[u8]) -> Result<LoadedWasmSandbox>
Load a Wasm module from a buffer of bytes into the sandbox and return a LoadedWasmSandbox
able to execute code in the loaded Wasm Module.
Before you can call guest functions in the sandbox, you must call this function and use the returned value to call guest functions.