Skip to main content

CallOptions

Struct CallOptions 

Source
pub struct CallOptions {
    pub deadline: Option<Instant>,
    pub routing_policy: RoutingPolicy,
    pub filter_unhealthy: bool,
    pub trace_context: Option<TraceContext>,
    pub max_in_flight_per_target: u32,
    pub stream_window_initial: Option<u32>,
    pub request_window_initial: Option<u32>,
    pub request_headers: Vec<(String, Vec<u8>)>,
    pub cancel_token: Option<u64>,
}
Expand description

Fields§

§deadline: Option<Instant>

Hard deadline for the call. The future returned by call races a tokio::time::sleep_until; whichever fires first wins. On timeout the caller emits a CANCEL event for call_id so the server can drop the in-flight handler. None means no deadline; the caller waits indefinitely (or until the future is dropped).

§routing_policy: RoutingPolicy

How call_service picks a target. Ignored by call (which takes an explicit target_node_id). Default: RoundRobin.

§filter_unhealthy: bool

Skip candidates whose ProximityGraph entry reports !is_available() (i.e. Unhealthy or Unknown). Default true. Candidates with no proximity entry at all are KEPT — absence of evidence is not evidence of unhealth, and a freshly-announced service shouldn’t be filtered just because pingwaves haven’t propagated yet.

§trace_context: Option<TraceContext>

W3C Trace Context to propagate to the server. When Some, the call sets FLAG_RPC_PROPAGATE_TRACE on the request and emits traceparent / tracestate headers; the server’s RpcContext::trace_context will be populated with the same values. nRPC is transport-only — application code on both sides reads / writes this via whatever tracing backend it has wired up (tracing-opentelemetry, Datadog, etc.).

§max_in_flight_per_target: u32

Per-call concurrency cap. Future Phase 2 work; v1 ignores this and the per-Mesh RpcClientPending doesn’t bound in-flight count.

§stream_window_initial: Option<u32>

Streaming responses only. Initial credit window for per-streaming-response flow control. When Some(n), the caller emits nrpc-stream-window-initial: n on the REQUEST and the server’s pump task awaits one credit per emitted chunk. The returned RpcStream auto-grants 1 credit per consumed chunk so the in-flight credit holds near n (or use RpcStream::grant for batched / custom cadence). None (the default) → unbounded: server pumps chunks as fast as the publish path can take them (back-compat / pre-flow-control behavior). Ignored by non-streaming call / call_service.

§request_window_initial: Option<u32>

Client-streaming / duplex only. Initial credit window for per-call request-direction flow control. Mirror of Self::stream_window_initial for the upload direction. When Some(n), the caller emits nrpc-request-window-initial: n on the REQUEST and its send().await sink awaits one credit per pushed chunk; the server refills via DISPATCH_RPC_REQUEST_GRANT events. None → unbounded: caller’s send sink doesn’t block (legacy / fast-path). Ignored by unary call / call_streaming.

Bidi streaming plan (Phase C).

§request_headers: Vec<(String, Vec<u8>)>

Caller-supplied request headers. Appended to the wire RpcRequestPayload::headers after any auto-generated headers (trace context, stream-window). Useful for application-level metadata the server needs at dispatch-time — e.g., the net-where predicate header (Phase 9b of CAPABILITY_SYSTEM_SDK_PLAN.md) that services consult for predicate-pushdown filtering.

Each entry is (name, value_bytes). Names use the lowercase cyberdeck-* / nrpc-* convention; the substrate doesn’t validate names beyond the MAX_RPC_HEADER_NAME_LEN cap enforced at encode time.

Default: empty.

§cancel_token: Option<u64>

Caller-side cancel token. Mint via MeshNode::reserve_cancel_token; pair with MeshNode::cancel from any thread to abort the in-flight call. None (or Some(0) — the “no token” sentinel) → no cancel slot is reserved and the call has no external abort path beyond Drop-on-future-cancellation.

Honored uniformly by every call shape: call, call_service, call_streaming, call_client_stream, call_duplex. The substrate registers the token in a per-mesh cancel registry at call construction and removes it on resolution (success, error, or Drop). A cancel that fires mid-flight surfaces to the caller as RpcError::Cancelled and emits CANCEL on the wire via the existing per-call-shape guards (UnaryCallGuard, ClientStreamCallRaw::Drop, DuplexCallRaw::Drop).

Cancel-before-register is race-safe: a cancel that arrives in the gap between reserve_cancel_token and the call’s internal register step latches a pre-cancel flag on the registry’s orphan entry; the subsequent register observes it and the call short-circuits to RpcError::Cancelled without ever publishing the REQUEST.

Trait Implementations§

Source§

impl CallOptionsExt for CallOptions

Source§

fn with_request_header( self, name: impl Into<String>, value: impl Into<Vec<u8>>, ) -> Self

Append a raw (name, value_bytes) request header. Names follow the lowercase cyberdeck-* / nrpc-* convention.
Source§

fn with_where(self, pred: &Predicate) -> Result<Self, PredicateRpcEncodeError>

Attach a net::adapter::net::behavior::Predicate as the net-where request header. The predicate rides as JSON-encoded PredicateWire bytes per the substrate’s predicate_to_rpc_header contract; services opting into predicate-pushdown decode via RpcContextExt::where_predicate. Read more
Source§

impl Clone for CallOptions

Source§

fn clone(&self) -> CallOptions

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 CallOptions

Source§

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

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

impl Default for CallOptions

Source§

fn default() -> CallOptions

Returns the “default value” for a type. Read more

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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