Creates a new [`Instance`] from the previously compiled [`Module`] and list of `imports` specified. This method instantiates the `module` provided with the `imports`, following the procedure in the [core specification][inst] to instantiate. Instantiation can fail for a number of reasons (many specified below), but if successful the `start` function will be automatically run (if specified in the `
(
mut store: impl AsContextMut,
module: &Module,
imports: &[Extern],
)
| 113 | /// memory allocation fails. See the `OutOfMemory` type's documentation for |
| 114 | /// details on Wasmtime's out-of-memory handling. |
| 115 | pub fn new( |
| 116 | mut store: impl AsContextMut, |
| 117 | module: &Module, |
| 118 | imports: &[Extern], |
| 119 | ) -> Result<Instance> { |
| 120 | let mut store = store.as_context_mut(); |
| 121 | store.0.validate_sync_call()?; |
| 122 | let imports = Instance::typecheck_externs(store.0, module, imports)?; |
| 123 | // Note that the unsafety here should be satisfied by the call to |
| 124 | // `typecheck_externs` above which satisfies the condition that all |
| 125 | // the imports are valid for this module. |
| 126 | vm::assert_ready(unsafe { |
| 127 | Instance::new_started(&mut store, module, imports.as_ref(), Asyncness::No) |
| 128 | }) |
| 129 | } |
| 130 | |
| 131 | /// Same as [`Instance::new`], except for usage in [asynchronous stores]. |
| 132 | /// |
nothing calls this directly
no test coverage detected