pub trait Registerable {
// Required method
fn register_host_function<Args: ParameterTuple, Output: SupportedReturnType>(
&mut self,
name: &str,
hf: impl Into<HostFunction<Output, Args>>,
) -> Result<()>;
}Expand description
Re-export for HostFunction trait
A sandbox on which (primitive) host functions can be registered
Required Methods§
Sourcefn register_host_function<Args: ParameterTuple, Output: SupportedReturnType>(
&mut self,
name: &str,
hf: impl Into<HostFunction<Output, Args>>,
) -> Result<()>
fn register_host_function<Args: ParameterTuple, Output: SupportedReturnType>( &mut self, name: &str, hf: impl Into<HostFunction<Output, Args>>, ) -> Result<()>
Register a primitive host function
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Registerable for HostFunctions
impl Registerable for MultiUseSandbox
Allow registering host functions on an already-evolved
crate::MultiUseSandbox.
The primary entry point for host-function registration is
crate::SandboxBuilder::host_function — that’s the lifecycle
phase where the guest hasn’t yet been allowed to issue host calls.
There are, however, cases where a MultiUseSandbox is obtained
without going through the builder:
- Sandboxes loaded from a persisted snapshot.
- Any future API that yields a
MultiUseSandboxdirectly.
In those cases the caller never had a chance to register up front, so we expose the same trait implementation here for late registration. The guest’s host-function dispatcher resolves by name at call time, so inserting into the registry after the sandbox is built is semantically safe as long as the first host-function invocation happens after registration completes.