#[host_fns]Expand description
This macro is used to define the expected host functions that are accessible to the module. It takes an optional namespace argument to specify the namespace of the host functions. If not provided, it defaults to “env”.
§Examples
#[host_fns(namespace = "env")]
unsafe extern "host" {
fn host_log(message: String);
fn host_add(a: i32, b: i32) -> i32;
}This allows calling the host functions in the module code like this:
#[mod_fn(name = "my_func")]
pub fn my_func() -> FnResult<()> {
unsafe { host_log("Hello from the plugin!".to_string()) }
let result = unsafe { host_add(1, 2) };
println!("Result from host_add: {}", result);
Ok(())
}