MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / get_module

Method get_module

crates/wasmtime/src/runtime/component/instance.rs:220–237  ·  view source on GitHub ↗

Looks up an exported module by name within this [`Instance`]. The `store` argument provided must be the store that this instance lives within and the `name` argument is the lookup key by which to find the exported module. If the module is found then `Some` is returned and otherwise `None` is returned. The `name` here can be a string such as `&str` or it can be a [`ComponentExportIndex`] which is

(
        &self,
        mut store: impl AsContextMut,
        name: impl ExportLookup,
    )

Source from the content-addressed store, hash-verified

218 ///
219 /// Panics if `store` does not own this instance.
220 pub fn get_module(
221 &self,
222 mut store: impl AsContextMut,
223 name: impl ExportLookup,
224 ) -> Option<Module> {
225 let store = store.as_context_mut().0;
226 let (instance, export) = self.lookup_export(store, name)?;
227 match export {
228 Export::ModuleStatic { index, .. } => {
229 Some(instance.component().static_module(*index).clone())
230 }
231 Export::ModuleImport { import, .. } => match instance.runtime_import(*import) {
232 RuntimeImport::Module(m) => Some(m.clone()),
233 _ => unreachable!(),
234 },
235 _ => None,
236 }
237 }
238
239 /// Looks up an exported resource type by name within this [`Instance`].
240 ///

Callers 9

instance_exportsFunction · 0.45
export_old_get_newFunction · 0.45
export_new_get_oldFunction · 0.45
export_missing_get_maxFunction · 0.45
usable_exported_modulesFunction · 0.45
moduleMethod · 0.45
frame_to_pcMethod · 0.45
frame_to_return_addrMethod · 0.45

Calls 6

lookup_exportMethod · 0.80
static_moduleMethod · 0.80
as_context_mutMethod · 0.45
cloneMethod · 0.45
componentMethod · 0.45
runtime_importMethod · 0.45

Tested by 3

export_old_get_newFunction · 0.36
export_new_get_oldFunction · 0.36