Skip to main content

WasmEdge_VMRegisterModuleFromImport

Function WasmEdge_VMRegisterModuleFromImport 

Source
pub unsafe extern "C" fn WasmEdge_VMRegisterModuleFromImport(
    Cxt: *mut WasmEdge_VMContext,
    ImportCxt: *const WasmEdge_ModuleInstanceContext,
) -> WasmEdge_Result
Expand description

Register a module instance in the store in the VM by exporting its module name.

After calling this function, the existing module instance will be registered in the store context in this VM, and the other modules can import the exported instances for linking during instantiation. Developers SHOULD guarantee the lifetime of this existing module instance, or an error will occur during execution after the module instance is destroyed if it has been imported by other modules. That is, developers should call the WasmEdge_ModuleInstanceDelete if this existing module instance will no longer be used or after the deletion of this VM. When the module instance is deleted, it will be unregistered from the store context in this VM automatically.

This function is thread-safe.

\param Cxt the WasmEdge_VMContext that contains the store. \param ImportCxt the WasmEdge_ModuleInstanceContext to register.

\returns WasmEdge_Result. Call WasmEdge_ResultGetMessage for the error message.