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

Method wrap

crates/wasmtime/src/runtime/func.rs:809–819  ·  view source on GitHub ↗

Creates a new `Func` from the given Rust closure. This function will create a new `Func` which, when called, will execute the given Rust closure. Unlike [`Func::new`] the target function being called is known statically so the type signature can be inferred. Rust types will map to WebAssembly types as follows: | Rust Argument Type | WebAssembly Type | |---

(
        store: impl AsContextMut<Data = T>,
        func: impl IntoFunc<T, Params, Results>,
    )

Source from the content-addressed store, hash-verified

807 /// # }
808 /// ```
809 pub fn wrap<T, Params, Results>(
810 store: impl AsContextMut<Data = T>,
811 func: impl IntoFunc<T, Params, Results>,
812 ) -> Func
813 where
814 T: 'static,
815 {
816 Self::try_wrap(store, func).expect(
817 "allocation failure during `Func::wrap` (use `Func::try_wrap` to handle such errors)",
818 )
819 }
820
821 /// Fallible version of [`Func::wrap`] that returns an error on
822 /// out-of-memory instead of panicking.

Callers

nothing calls this directly

Calls 7

funcFunction · 0.85
OkFunction · 0.85
chainMethod · 0.80
into_fallibleMethod · 0.80
sub_callerMethod · 0.80
expectMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected