Skip to main content

register_host_function

Macro register_host_function 

Source
macro_rules! register_host_function {
    ($linker:expr, $name:expr, |mut $controller:ident : $controller_ty:ty, $arg:ident : $arg_ty:ty| -> Result<$ret:ty> $body:tt) => { ... };
    ($linker:expr, $name:expr, |mut $controller:ident : $controller_ty:ty, $($arg:ident : $arg_ty:ty),+| -> Result<$ret:ty> $body:tt) => { ... };
    ($linker:expr, $name:expr, |$controller:ident : $controller_ty:ty, $($arg:ident : $arg_ty:ty),+| -> Result<$ret:ty> $body:tt) => { ... };
}
Expand description

Macro to register an async host function with automatic argument conversion and error handling. Returns -1 on error (logged to stderr), positive values are valid pointers. Uses Wasmtime’s native async support with func_wrap_async.