pub struct RpcRequestPayload {
pub service: String,
pub deadline_ns: u64,
pub flags: u16,
pub headers: Vec<RpcHeader>,
pub body: Bytes,
}Expand description
nRPC request payload. Lives after the 24-byte EventMeta prefix
in a DISPATCH_RPC_REQUEST event.
Fields§
§service: StringService-name dispatch key. The server’s fold looks this up
in its serve_rpc registry and routes to the registered
handler.
deadline_ns: u64Absolute deadline (unix nanos). 0 means no deadline; the
caller will cancel via DISPATCH_RPC_CANCEL if it changes
its mind.
flags: u16Bitfield of FLAG_RPC_* constants.
headers: Vec<RpcHeader>Headers (trace context, idempotency key, content-type, etc.).
Capped at MAX_RPC_HEADERS entries, name <= MAX_RPC_HEADER_NAME_LEN,
value <= MAX_RPC_HEADER_VALUE_LEN.
body: BytesApplication-defined request body. Caller and server agree on the codec out-of-band; nRPC doesn’t interpret these bytes.
Held as Bytes so Self::decode can zero-copy slice_ref
the body out of the inbound event’s Bytes payload — pre-fix
perf #84 in docs/performance/net-perf-analysis.md this was
Vec<u8> and every decode did a data[body_start..body_end].to_vec()
(a memcpy per frame). For high-RPS systems doing 100K+ RPCs/sec
with 1 KB+ bodies that was 100+ MB/sec of pure memcpy.
Implementations§
Source§impl RpcRequestPayload
impl RpcRequestPayload
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Compute the encoded byte length WITHOUT actually encoding.
Used by request_wire_size and any caller that needs to
budget event size at the bus layer (e.g., to refuse a
request that wouldn’t fit in the configured packet budget)
without paying the encode cost.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encode to the wire format. The result is the bytes that
follow the 24-byte EventMeta prefix in the RedEX payload.
Encoder bounds: every field that has a MAX_RPC_* cap
is asserted against that cap. In debug builds an oversize
field panics with a useful diagnostic so the programmer
notices in tests; in release builds the assert is dropped
(the decoder side still enforces the cap, so a malformed
frame would be rejected by the receiver — but constructing
one is always a caller bug).
Sourcepub fn decode(data: Bytes) -> Result<Self, RpcCodecError>
pub fn decode(data: Bytes) -> Result<Self, RpcCodecError>
Decode from the wire bytes following the EventMeta prefix.
All length fields are bounded by the MAX_RPC_* constants;
over-cap inputs error rather than allocate unbounded
buffers.
Takes Bytes (not &[u8]) so the decoded body field
can be a zero-copy data.slice(..) instead of an owned
to_vec — see perf #84.
Trait Implementations§
Source§impl Clone for RpcRequestPayload
impl Clone for RpcRequestPayload
Source§fn clone(&self) -> RpcRequestPayload
fn clone(&self) -> RpcRequestPayload
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RpcRequestPayload
impl Debug for RpcRequestPayload
Source§impl PartialEq for RpcRequestPayload
impl PartialEq for RpcRequestPayload
Source§fn eq(&self, other: &RpcRequestPayload) -> bool
fn eq(&self, other: &RpcRequestPayload) -> bool
self and other values to be equal, and is used by ==.impl Eq for RpcRequestPayload
impl StructuralPartialEq for RpcRequestPayload
Auto Trait Implementations§
impl !Freeze for RpcRequestPayload
impl RefUnwindSafe for RpcRequestPayload
impl Send for RpcRequestPayload
impl Sync for RpcRequestPayload
impl Unpin for RpcRequestPayload
impl UnsafeUnpin for RpcRequestPayload
impl UnwindSafe for RpcRequestPayload
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.