Skip to main content

Module rpc

Module rpc 

Source
Expand description

Wire envelope for the host ↔ guest RPC.

Both directions (host → guest function call, guest → host callback) use the same Request / Response shapes. The payload is opaque bytes — each fn_id defines its own inner codec (today: rkyv-archived domain types like nub_arch_x86_abi::{InvocationSpec, InvocationResult}).

§Wire layout

Serializing a Request or Response with rkyv::to_bytes produces an AlignedVec<u8> that contains:

  1. An archived Request/Response whose payload field is an ArchivedVec<u8> (the bytes laid out inline).
  2. The rkyv root pointer trailer (a relative offset + length).

Readers run rkyv::access::<ArchivedRequest, _>(&bytes) (with bytecheck) and pull archived.payload.as_ref() -> &[u8] to reach the inner payload — zero allocation, single pointer cast plus the cheap bytecheck pass.

Direction is encoded by which shared-memory ring the bytes live in (host’s input vs output ring), not by the type.

Structs§

ArchivedRequest
An archived Request
ArchivedResponse
An archived Response
Request
Host → guest function call OR guest → host callback. The payload is opaque to the envelope: the fn_id selects what inner codec applies.
RequestResolver
The resolver for an archived Request
Response
Reply to a Request. status == 0 means OK; non-zero is a receiver-defined error code with the human-readable detail in error_msg (mostly for debugging).
ResponseResolver
The resolver for an archived Response