Module mux

Module mux 

Source
Expand description

Multi-slot / multi-client concurrency for lease-backed RPC.

The RpcMuxClient and RpcMuxServer types multiplex several independent RPC slots into a single MemLease. Each slot has its own status byte so that multiple clients can have requests in flight simultaneously.

§Slot wire layout

All slots are contiguous in the leased arena. Each slot is SLOT_HEADER_SIZE + slot_payload_size bytes:

[request_id: u64 LE (8B)]
[method_id:  u32 LE (4B)]
[status:     u8      (1B)]
[reserved:   [u8; 3] (3B)]   // alignment padding
[payload_len:u32 LE (4B)]
[payload:    [u8; slot_payload_size]]

SLOT_HEADER_SIZE = 20 bytes (8 + 4 + 1 + 3 + 4).

Slot i begins at byte offset i * (SLOT_HEADER_SIZE + slot_payload_size).

Structs§

RpcMuxClient
Multi-slot RPC client.
RpcMuxServer
Multi-slot RPC server.

Constants§

DEFAULT_NUM_SLOTS
Default number of slots in a mux arena.
DEFAULT_SLOT_PAYLOAD_SIZE
Default payload capacity per slot (bytes).
SLOT_HEADER_SIZE
Header size per slot: request_id(8) + method_id(4) + status(1) + reserved(3) + payload_len(4) = 20 bytes.