pub trait Registerable {
// Required method
fn register_host_function(&mut self, fn_id: u32, func: HostFn) -> Result<()>;
}Expand description
A sandbox on which host functions can be registered.
Required Methods§
Implementors§
impl Registerable for MultiUseSandbox
Allow registering host functions on an already-evolved
crate::MultiUseSandbox.
The primary entry point for host-function registration is the
UninitializedSandbox impl above — 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 traversing the Uninitialized → evolve() path:
- Sandboxes loaded from a persisted snapshot.
- Any future API that yields a
MultiUseSandboxdirectly.
In those cases the caller never had a chance to call
register_host_function on an UninitializedSandbox, so we
expose the same trait implementation here for late registration.
The guest’s dispatcher resolves by fn_id at call time, so
inserting into the registry after evolve() is semantically safe
as long as the first host-function invocation happens after
registration completes.