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

Method func_wrap

crates/wasmtime/src/runtime/linker.rs:560–570  ·  view source on GitHub ↗

Define a host function within this linker. For information about how the host function operates, see [`Func::wrap`]. That includes information about translating Rust types to WebAssembly native types. This method creates a host-provided function in this linker under the provided name. This method is distinct in its capability to create a [`Store`](crate::Store)-independent function. This means t

(
        &mut self,
        module: &str,
        name: &str,
        func: impl IntoFunc<T, Params, Args>,
    )

Source from the content-addressed store, hash-verified

558 /// memory allocation fails. See the `OutOfMemory` type's documentation for
559 /// details on Wasmtime's out-of-memory handling.
560 pub fn func_wrap<Params, Args>(
561 &mut self,
562 module: &str,
563 name: &str,
564 func: impl IntoFunc<T, Params, Args>,
565 ) -> Result<&mut Self>
566 where
567 T: 'static,
568 {
569 self.func_insert(module, name, func.into_func(&self.engine)?)
570 }
571
572 /// Asynchronous analog of [`Linker::func_wrap`].
573 #[cfg(feature = "async")]

Callers 15

make_linkerFunction · 0.45
bench_callsFunction · 0.45
bench_sequentialFunction · 0.45
bench_parallelFunction · 0.45
async_then_sync_trapFunction · 0.45
sync_then_async_trapFunction · 0.45
typed_v128_importsFunction · 0.45
wrap_and_typed_i31refFunction · 0.45
call_linked_funcFunction · 0.45
recursionFunction · 0.45

Calls 2

func_insertMethod · 0.80
into_funcMethod · 0.45

Tested by 15

call_linked_funcFunction · 0.36
recursionFunction · 0.36
trappingFunction · 0.36
wrap_funcFunction · 0.36
drop_funcFunction · 0.36
signatures_matchFunction · 0.36
call_wrapped_funcFunction · 0.36
store_with_contextFunction · 0.36
link_twice_badFunction · 0.36