pub trait InstantiationHook:
Debug
+ Send
+ Sync
+ 'static {
// Provided methods
fn additional_imports(
&self,
module: &Module,
store: &mut StoreMut<'_>,
) -> Result<(Imports, InstantiationState)> { ... }
fn configure_new_instance(
&self,
module: &Module,
store: &mut StoreMut<'_>,
instance: &Instance,
imported_memory: Option<&Memory>,
state: InstantiationState,
) -> Result<()> { ... }
}Expand description
A hook into the instantiation of WASIX module instances.
Registered on PluggableRuntime::with_instantiation_hook or
OverriddenRuntime::with_instantiation_hook, and invoked once per
instance the runtime creates (process bootstrap, thread spawn, dynamically
linked side module).
Both methods have a no-op default, so an implementation only needs to provide the phases it cares about.
Provided Methods§
Sourcefn additional_imports(
&self,
module: &Module,
store: &mut StoreMut<'_>,
) -> Result<(Imports, InstantiationState)>
fn additional_imports( &self, module: &Module, store: &mut StoreMut<'_>, ) -> Result<(Imports, InstantiationState)>
Creates additional imports for an instance about to be created in
store.
The returned InstantiationState is handed back to
InstantiationHook::configure_new_instance for the instance built
with these imports. If instantiation fails, the state is dropped.
Sourcefn configure_new_instance(
&self,
module: &Module,
store: &mut StoreMut<'_>,
instance: &Instance,
imported_memory: Option<&Memory>,
state: InstantiationState,
) -> Result<()>
fn configure_new_instance( &self, module: &Module, store: &mut StoreMut<'_>, instance: &Instance, imported_memory: Option<&Memory>, state: InstantiationState, ) -> Result<()>
Configures an instantiated instance before initialization/startup.
state is the InstantiationState this hook returned from the
InstantiationHook::additional_imports call whose imports the
instance was created with.