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,
)
| 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 | /// |