Skip to main content

Crate nub_host_guest_macro

Crate nub_host_guest_macro 

Source
Expand description

Proc macros for the nub guest runtime.

Forked from hyperlight-guest-macro 0.15.0 (Apache-2.0), stripped of name-based + parameter-polymorphic registration. The single attribute #[guest_function(fn_id = N)] registers a guest function under an integer fn_id chosen at compile time. The dispatcher in nub-arch-guestbin matches on fn_id and calls into the registered function pointer.

The function being annotated must have signature fn(&[u8]) -> Vec<u8> (the request payload bytes → response payload bytes). Typed encode/decode is the caller’s job — the macro stays out of the codec layer.

#[host_function] is forked too: the wrapper around nub_arch_guestbin::host_comm::call_host_raw(fn_id, &bytes) for guest→host RPC. The #[main] and #[dispatch] upstream attributes are dropped; we use the weak-linkage default for hyperlight_main and hand-wire the dispatcher.

Attribute Macros§

guest_function
Register a guest function under a compile-time fn_id.
host_function
Generate a host-function wrapper that issues a guest→host RPC.