pub trait IrohRequestProcessor:
Sealed
+ Send
+ Sync
+ 'static {
// Required method
fn process(
&self,
request: Bytes,
carrier: CarrierContext,
) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + '_>>;
// Provided methods
fn close_admission(&self) { ... }
fn begin_shutdown(&self, deadline: Instant) -> Instant { ... }
}Expand description
Sealed trait used to wire actual request processing.
The processor receives the raw request bytes (a Cap’n Proto-encoded
SignedEnvelope) and returns the raw response bytes.
Contract for process:
Ok(bytes)—bytesMUST be a valid Cap’n Proto-encodedResponseEnvelopeand is written verbatim to the bidi stream. Application-layer errors (verification failure, handler error, etc.) MUST be returned this way as signed error envelopes — the server forwards them unchanged.Err(_)— admission or wire-level fatal. Untrusted network carriers silently reset/drop the stream so unauthenticated input cannot trigger a signed response. Trusted local carriers retain the legacy signed stub error for transport-only callers.
Implementations are crate-owned so arbitrary raw-byte callbacks cannot
become an application-facing network boundary. Services use
super::iroh_rpc::LocalServiceBridge, including !Send services.
The carrier argument is the accept boundary’s attestation of which
carrier class the request arrived on (INV-2 receive side, #1042). It is a
required parameter — a processor cannot be invoked without a carrier
classification, so a forgotten context is a compile error, not a silent
fail-open. On an untrusted carrier, the serve loop invokes only the
crate-owned canonical dispatch processor.
(Name retained from the iroh-only era to avoid churn in callers.)
Required Methods§
fn process( &self, request: Bytes, carrier: CarrierContext, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + '_>>
Provided Methods§
Sourcefn close_admission(&self)
fn close_admission(&self)
Close service admission before removing an in-process endpoint. The owning bridge performs the bounded drain and join separately.
Sourcefn begin_shutdown(&self, deadline: Instant) -> Instant
fn begin_shutdown(&self, deadline: Instant) -> Instant
Close admission and establish one absolute request-drain deadline. A bridge returns its first deadline so later carrier/owner calls cannot restart the grace period. Joining remains the service owner’s duty.