Looks up an exported resource type 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 resource. If the resource 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
(
&self,
mut store: impl AsContextMut,
name: impl ExportLookup,
)
| 253 | /// |
| 254 | /// Panics if `store` does not own this instance. |
| 255 | pub fn get_resource( |
| 256 | &self, |
| 257 | mut store: impl AsContextMut, |
| 258 | name: impl ExportLookup, |
| 259 | ) -> Option<ResourceType> { |
| 260 | let store = store.as_context_mut().0; |
| 261 | let (instance, export) = self.lookup_export(store, name)?; |
| 262 | match export { |
| 263 | Export::Type(TypeDef::Resource(id)) => { |
| 264 | Some(InstanceType::new(instance).resource_type(*id)) |
| 265 | } |
| 266 | Export::Type(_) |
| 267 | | Export::LiftedFunction { .. } |
| 268 | | Export::ModuleStatic { .. } |
| 269 | | Export::ModuleImport { .. } |
| 270 | | Export::Instance { .. } => None, |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /// A methods similar to [`Component::get_export`] except for this |
| 275 | /// instance. |