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

Method func_wrap

crates/wasmtime/src/runtime/component/linker.rs:473–481  ·  view source on GitHub ↗

Defines a new host-provided function into this [`LinkerInstance`]. This method is used to give host functions to wasm components. The `func` provided will be callable from linked components with the type signature dictated by `Params` and `Return`. The `Params` is a tuple of types that will come from wasm and `Return` is a value coming from the host going back to wasm. Additionally the `func` ta

(&mut self, name: &str, func: F)

Source from the content-addressed store, hash-verified

471 //
472 // TODO: needs more words and examples
473 pub fn func_wrap<F, Params, Return>(&mut self, name: &str, func: F) -> Result<()>
474 where
475 F: Fn(StoreContextMut<T>, Params) -> Result<Return> + Send + Sync + 'static,
476 Params: ComponentNamedList + Lift + 'static,
477 Return: ComponentNamedList + Lower + 'static,
478 {
479 self.insert(name, Definition::Func(HostFunc::func_wrap(func)?))?;
480 Ok(())
481 }
482
483 /// Defines a new host-provided async function into this [`LinkerInstance`].
484 ///

Callers

nothing calls this directly

Calls 3

OkFunction · 0.85
FuncClass · 0.70
insertMethod · 0.45

Tested by

no test coverage detected