Define a new host-provided function using dynamically typed values. The `name` provided is the name of the function to define and the `func` provided is the host-defined closure to invoke when this function is called. This function is the "dynamic" version of defining a host function as compared to [`LinkerInstance::func_wrap`]. With [`LinkerInstance::func_wrap`] a function's type is statically
(
&mut self,
name: &str,
func: impl Fn(StoreContextMut<'_, T>, types::ComponentFunc, &[Val], &mut [Val]) -> Result<()>
+ Send
+ Sync
+ 'static,
)
| 698 | /// memory allocation fails. See the `OutOfMemory` type's documentation for |
| 699 | /// details on Wasmtime's out-of-memory handling. |
| 700 | pub fn func_new( |
| 701 | &mut self, |
| 702 | name: &str, |
| 703 | func: impl Fn(StoreContextMut<'_, T>, types::ComponentFunc, &[Val], &mut [Val]) -> Result<()> |
| 704 | + Send |
| 705 | + Sync |
| 706 | + 'static, |
| 707 | ) -> Result<()> { |
| 708 | self.insert(name, Definition::Func(HostFunc::func_new(func)?))?; |
| 709 | Ok(()) |
| 710 | } |
| 711 | |
| 712 | /// Define a new host-provided async function using dynamic types. |
| 713 | /// |