pub struct HostFunction { /* private fields */ }Expand description
A host function callable from WASM, wrapping a native closure with its declared WASM signature.
Implementations§
Source§impl HostFunction
impl HostFunction
Sourcepub fn new(
ty: FuncType,
func: impl FnMut(&[Value]) -> Result<Vec<Value>, RuntimeError> + 'static,
) -> Self
pub fn new( ty: FuncType, func: impl FnMut(&[Value]) -> Result<Vec<Value>, RuntimeError> + 'static, ) -> Self
Wrap a closure with its WASM signature. The signature is checked against the import declaration at registration; argument values are passed positionally and results must match the declared result types.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for HostFunction
impl !Send for HostFunction
impl !Sync for HostFunction
impl !UnwindSafe for HostFunction
impl Freeze for HostFunction
impl Unpin for HostFunction
impl UnsafeUnpin for HostFunction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more