use examples_common::get_wasm_module_path;
use hyperlight_wasm::SandboxBuilder;
fn main() {
let mut proto_wasm_sandbox = SandboxBuilder::new()
.with_guest_input_buffer_size(0x40000)
.with_guest_heap_size(0x70000)
.build()
.unwrap();
let host_func = |a: i32| {
println!("host_func called with {}", a);
a + 1
};
proto_wasm_sandbox
.register("TestHostFunc", host_func)
.unwrap();
let wasm_sandbox = proto_wasm_sandbox.load_runtime().unwrap();
let mut loaded_wasm_sandbox = {
let mod_path = get_wasm_module_path("rust_wasm_samples.aot").unwrap();
wasm_sandbox.load_module(mod_path)
}
.unwrap();
let result: i32 = loaded_wasm_sandbox
.call_guest_function("call_host_function", 5i32)
.unwrap();
println!("got result: {:?} from the host function!", result);
}