Convenience wrapper to define an entire [`Instance`] in this linker. This function is a convenience wrapper around [`Linker::define`] which will define all exports on `instance` into this linker. The module name for each export is `module_name`, and the name for each export is the name in the instance itself. Note that when this API is used the [`Linker`] is no longer compatible with multi-[`Sto
(
&mut self,
mut store: impl AsContextMut<Data = T>,
module_name: &str,
instance: Instance,
)
| 648 | /// memory allocation fails. See the `OutOfMemory` type's documentation for |
| 649 | /// details on Wasmtime's out-of-memory handling. |
| 650 | pub fn instance( |
| 651 | &mut self, |
| 652 | mut store: impl AsContextMut<Data = T>, |
| 653 | module_name: &str, |
| 654 | instance: Instance, |
| 655 | ) -> Result<&mut Self> |
| 656 | where |
| 657 | T: 'static, |
| 658 | { |
| 659 | let mut store = store.as_context_mut(); |
| 660 | let exports: TryVec<_> = instance |
| 661 | .exports(&mut store) |
| 662 | .map(|e| { |
| 663 | Ok(( |
| 664 | self.import_key(module_name, Some(e.name()))?, |
| 665 | e.into_extern(), |
| 666 | )) |
| 667 | }) |
| 668 | .try_collect::<_, Error>()?; |
| 669 | for (key, export) in exports { |
| 670 | self.insert(key, Definition::new(store.0, export))?; |
| 671 | } |
| 672 | Ok(self) |
| 673 | } |
| 674 | |
| 675 | /// Define automatic instantiations of a [`Module`] in this linker. |
| 676 | /// |
no test coverage detected