Skip to main content

InitContext

Trait InitContext 

Source
pub trait InitContext<F: Factor> {
    type StoreData: Send + 'static;

    // Required methods
    fn linker(&mut self) -> &mut Linker<Self::StoreData>;
    fn get_data_with_table(
        store: &mut Self::StoreData,
    ) -> (&mut FactorInstanceState<F>, &mut ResourceTable);

    // Provided methods
    fn get_data(store: &mut Self::StoreData) -> &mut FactorInstanceState<F> { ... }
    fn link_bindings(
        &mut self,
        add_to_linker: impl Fn(&mut Linker<Self::StoreData>, fn(&mut Self::StoreData) -> &mut FactorInstanceState<F>) -> Result<()>,
    ) -> Result<()> { ... }
}
Expand description

An InitContext is passed to Factor::init, giving access to the global common wasmtime::component::Linker.

Required Associated Types§

Source

type StoreData: Send + 'static

The T in Store<T>.

Required Methods§

Source

fn linker(&mut self) -> &mut Linker<Self::StoreData>

Returns a mutable reference to the wasmtime::component::Linker.

Source

fn get_data_with_table( store: &mut Self::StoreData, ) -> (&mut FactorInstanceState<F>, &mut ResourceTable)

Get the instance state for this factor from the store’s state, with the resource table as well.

Provided Methods§

Source

fn get_data(store: &mut Self::StoreData) -> &mut FactorInstanceState<F>

Get the instance state for this factor from the store’s state.

Convenience method to link a binding to the linker.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§