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

Method new_async

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

Source from the content-addressed store, hash-verified

523 /// ```
524 #[cfg(feature = "async")]
525 pub fn new_async<T, F>(mut store: impl AsContextMut<Data = T>, ty: FuncType, func: F) -> Func
526 where
527 F: for<'a> Fn(
528 Caller<'a, T>,
529 &'a [Val],
530 &'a mut [Val],
531 ) -> Box<dyn Future<Output = Result<()>> + Send + 'a>
532 + Send
533 + Sync
534 + 'static,
535 T: Send + 'static,
536 {
537 let store = store.as_context_mut().0;
538
539 let host = HostFunc::new_async(store.engine(), ty, func).panic_on_oom();
540
541 // SAFETY: the `T` used by `func` matches the `T` of the store we're
542 // inserting into via this function's type signature.
543 unsafe { host.into_func(store).panic_on_oom() }
544 }
545
546 /// Creates a new `Func` from a store and a funcref within that store.
547 ///

Callers

nothing calls this directly

Calls 12

OkFunction · 0.85
fromFunction · 0.85
funcFunction · 0.85
panic_on_oomMethod · 0.80
sub_callerMethod · 0.80
newFunction · 0.50
as_context_mutMethod · 0.45
engineMethod · 0.45
into_funcMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45
paramsMethod · 0.45

Tested by

no test coverage detected