Fallible version of [`Func::wrap`] that returns an error on out-of-memory instead of panicking. # Errors This function will return an [`OutOfMemory`][crate::OutOfMemory] error when memory allocation fails. See the `OutOfMemory` type's documentation for details on Wasmtime's out-of-memory handling.
(
mut store: impl AsContextMut<Data = T>,
func: impl IntoFunc<T, Params, Results>,
)
| 827 | /// memory allocation fails. See the `OutOfMemory` type's documentation for |
| 828 | /// details on Wasmtime's out-of-memory handling. |
| 829 | pub fn try_wrap<T, Params, Results>( |
| 830 | mut store: impl AsContextMut<Data = T>, |
| 831 | func: impl IntoFunc<T, Params, Results>, |
| 832 | ) -> Result<Func> |
| 833 | where |
| 834 | T: 'static, |
| 835 | { |
| 836 | let store = store.as_context_mut().0; |
| 837 | let engine = store.engine(); |
| 838 | let host = func.into_func(engine)?; |
| 839 | |
| 840 | // SAFETY: The `T` the closure takes is the same as the `T` of the store |
| 841 | // we're inserting into via the type signature above. |
| 842 | Ok(unsafe { host.into_func(store)? }) |
| 843 | } |
| 844 | |
| 845 | /// Same as [`Func::wrap`], except the closure asynchronously produces the |
| 846 | /// result and the arguments are passed within a tuple. For more information |
nothing calls this directly
no test coverage detected