Skip to main content

RpcRequestPayload

Struct RpcRequestPayload 

Source
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: String

Service-name dispatch key. The server’s fold looks this up in its serve_rpc registry and routes to the registered handler.

§deadline_ns: u64

Absolute deadline (unix nanos). 0 means no deadline; the caller will cancel via DISPATCH_RPC_CANCEL if it changes its mind.

§flags: u16

Bitfield 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: Bytes

Application-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

Source

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.

Source

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).

Source

pub fn encode_into(&self, buf: &mut Vec<u8>)

Encode directly into buf, appending the wire bytes (audit T2.2). Callers that already hold an EventMeta-prefixed buffer use this to skip encode()’s intermediate Vec allocation + copy. Produces the identical bytes encode() returns. Pre-reserve(encoded_len()) for an exact-fit single allocation when starting from an empty buffer.

Source

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

Source§

fn clone(&self) -> RpcRequestPayload

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RpcRequestPayload

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RpcRequestPayload

Source§

impl PartialEq for RpcRequestPayload

Source§

fn eq(&self, other: &RpcRequestPayload) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RpcRequestPayload

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more