From a5d49c07a7fb10209529e00040f5bf761c22d7fa Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 4 Mar 2021 12:57:28 -0800 Subject: [PATCH] wasmtime: add `Linker::instantiate_async` to go with `Instance::new_async` --- crates/wasmtime/src/linker.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/wasmtime/src/linker.rs b/crates/wasmtime/src/linker.rs index 5875cf8891..e5397556f9 100644 --- a/crates/wasmtime/src/linker.rs +++ b/crates/wasmtime/src/linker.rs @@ -601,6 +601,16 @@ impl Linker { Instance::new(&self.store, module, &imports) } + /// Attempts to instantiate the `module` provided. This is the same as [`Linker::instantiate`], + /// except for async `Store`s. + #[cfg(feature = "async")] + #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + pub async fn instantiate_async(&self, module: &Module) -> Result { + let imports = self.compute_imports(module)?; + + Instance::new_async(&self.store, module, &imports).await + } + fn compute_imports(&self, module: &Module) -> Result> { module .imports()