MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wrap_async

Method wrap_async

crates/wasmtime/src/runtime/func.rs:849–865  ·  view source on GitHub ↗
(mut store: impl AsContextMut<Data = T>, func: F)

Source from the content-addressed store, hash-verified

847 /// see the [`Func`] documentation.
848 #[cfg(feature = "async")]
849 pub fn wrap_async<T, F, P, R>(mut store: impl AsContextMut<Data = T>, func: F) -> Func
850 where
851 F: for<'a> Fn(Caller<'a, T>, P) -> Box<dyn Future<Output = R> + Send + 'a>
852 + Send
853 + Sync
854 + 'static,
855 P: WasmTyList,
856 R: WasmRet,
857 T: Send + 'static,
858 {
859 let store = store.as_context_mut().0;
860 let host = HostFunc::wrap_async(store.engine(), func).panic_on_oom();
861
862 // SAFETY: The `T` the closure takes is the same as the `T` of the store
863 // we're inserting into via the type signature above.
864 unsafe { host.into_func(store).panic_on_oom() }
865 }
866
867 /// Returns the underlying wasm type that this `Func` has.
868 ///

Callers

nothing calls this directly

Calls 12

fromFunction · 0.85
funcFunction · 0.85
OkFunction · 0.85
panic_on_oomMethod · 0.80
chainMethod · 0.80
sub_callerMethod · 0.80
into_fallibleMethod · 0.80
newFunction · 0.50
as_context_mutMethod · 0.45
engineMethod · 0.45
into_funcMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected