nx_rpc.nx
buildroot/runtime/nx_rpc.nx
about
nx_rpc.nx -- typed RPC over nx_net_chan_blob.
Builds on nx_net_chan_blob's variable-length frames to give a
request/response pattern: caller sends (method_id, request_blob),
server dispatches to a registered handler indexed by method_id,
returns (response_blob). Wire format per exchange:
client -> server:
8 bytes: method_id (i64 big-endian via nx_net_chan_send)
N bytes: request blob (length-prefix framed via
nx_net_chan_send_blob)
server -> client:
N bytes: response blob (length-prefix framed)
Sentinel method_id NX_RPC_SHUTDOWN signals server to exit cleanly.
Handler table: a fixed-size array indexed by method_id. Each
entry is a typed fn-ptr: func(*u8, n_req, *u8, max_resp) -> n_resp.
Unregistered methods get a -1 response.
Composes against: [[nx_net_chan_tcp_i64]] (method_id transport),
[[nx_net_chan_blob_framing]] (request/response payload),
[[fn_ptr_indirect_call]] (typed dispatch).
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_atom.nxnx_net_chan.nx
imported by: nx_rpc_test.nx
structs
| 38 | struct NxRpcHandlerEntry |
| 45 | struct NxRpcServer |
consts
| 35 | const NX_RPC_SHUTDOWN: i64 = -1 |
| 36 | const NX_RPC_MAX_METHODS: i64 = 64 |
| 43 | const NX_RPC_ENTRY_BYTES: i64 = 16 |
functions
| 52 | func _nx_rpc_handler_at(s: *NxRpcServer, idx: i64) -> *NxRpcHandlerEntry |
| 59 | func nx_rpc_server_new(nc: *NxNetChan) -> *NxRpcServer |
| 72 | func nx_rpc_register(s: *NxRpcServer, method_id: i64, |
| 86 | func nx_rpc_server_run(s: *NxRpcServer, scratch_buf: *u8, scratch_cap: i64) -> i64 |
| 133 | func nx_rpc_call(nc: *NxNetChan, method_id: i64, |
| 142 | func nx_rpc_shutdown_call(nc: *NxNetChan) -> i64 |
| 147 | func nx_rpc_server_calls(s: *NxRpcServer) -> i64 calls 1: nx_atom_load_i64 |