pub trait ModuleRuntimeInfo: Send + Sync + 'static {
    // Required methods
    fn module(&self) -> &Arc<Module>;
    fn function(&self, index: DefinedFuncIndex) -> *mut VMFunctionBody;
    fn memory_image(
        &self,
        memory: DefinedMemoryIndex
    ) -> Result<Option<&Arc<MemoryImage>>>;
    fn unique_id(&self) -> Option<CompiledModuleId>;
    fn wasm_data(&self) -> &[u8] ;
    fn signature_ids(&self) -> &[VMSharedSignatureIndex];
    fn offsets(&self) -> &VMOffsets<HostPtr>;
}
Expand description

Functionality required by this crate for a particular module. This is chiefly needed for lazy initialization of various bits of instance state.

When an instance is created, it holds an Arc so that it can get to signatures, metadata on functions, memory and funcref-table images, etc. All of these things are ordinarily known by the higher-level layers of Wasmtime. Specifically, the main implementation of this trait is provided by wasmtime::module::ModuleInner. Since the runtime crate sits at the bottom of the dependence DAG though, we don’t know or care about that; we just need some implementor of this trait for each allocation request.

Required Methods§

source

fn module(&self) -> &Arc<Module>

The underlying Module.

source

fn function(&self, index: DefinedFuncIndex) -> *mut VMFunctionBody

Returns the address, in memory, that the function index resides at.

source

fn memory_image( &self, memory: DefinedMemoryIndex ) -> Result<Option<&Arc<MemoryImage>>>

Returns the MemoryImage structure used for copy-on-write initialization of the memory, if it’s applicable.

source

fn unique_id(&self) -> Option<CompiledModuleId>

A unique ID for this particular module. This can be used to allow for fastpaths to optimize a “re-instantiate the same module again” case.

source

fn wasm_data(&self) -> &[u8]

A slice pointing to all data that is referenced by this instance.

source

fn signature_ids(&self) -> &[VMSharedSignatureIndex]

Returns an array, indexed by SignatureIndex of all VMSharedSignatureIndex entries corresponding to the SignatureIndex.

source

fn offsets(&self) -> &VMOffsets<HostPtr>

Offset information for the current host.

Implementors§