pub struct JSSandbox { /* private fields */ }Expand description
A Hyperlight Sandbox with a JavaScript run time loaded but no guest code. A Hyperlight Sandbox with a JavaScript run time loaded but no guest code.
Implementations§
Source§impl JSSandbox
impl JSSandbox
Sourcepub fn add_handler<F>(&mut self, function_name: F, script: Script) -> Result<()>
pub fn add_handler<F>(&mut self, function_name: F, script: Script) -> Result<()>
Adds a new handler function to the sandboxes collection of handlers. This Handler will be
available to the host to call once get_loaded_sandbox is called.
Sourcepub fn remove_handler(&mut self, function_name: &str) -> Result<()>
pub fn remove_handler(&mut self, function_name: &str) -> Result<()>
Removes a handler function from the sandboxes collection of handlers.
Sourcepub fn clear_handlers(&mut self)
pub fn clear_handlers(&mut self)
Clears all handlers from the sandbox.
Sourcepub fn poisoned(&self) -> bool
pub fn poisoned(&self) -> bool
Returns whether the sandbox is currently poisoned.
A poisoned sandbox is in an inconsistent state due to the guest not running to completion.
This can happen when guest execution is interrupted (e.g., via InterruptHandle::kill()),
when the guest panics, or when memory violations occur.
Sourcepub fn get_loaded_sandbox(self) -> Result<LoadedJSSandbox>
pub fn get_loaded_sandbox(self) -> Result<LoadedJSSandbox>
Creates a new LoadedJSSandbox with the handlers that have been added to this JSSandbox.