pub struct RequestCtx { /* private fields */ }Expand description
Per-request context. Retains the full route handle and correlation id, provides interim stream emission, and exposes a cancellation signal.
Implementations§
Source§impl RequestCtx
impl RequestCtx
Sourcepub fn module_handle(&self) -> ModuleHandle
pub fn module_handle(&self) -> ModuleHandle
Clone the connection’s control handle, for readiness and other module RPCs.
Sourcepub fn request_payload(&self) -> Result<Option<(Value, &[u8])>, FramedBodyError>
pub fn request_payload(&self) -> Result<Option<(Value, &[u8])>, FramedBodyError>
Decodes a framed request only when ingress carried FLAG_BINARY.
Call this only for management operations that declared operation_payload.
Return a malformed body’s named error as a refusal before doing any work;
the serve helper deliberately leaves that policy to the handler.
Sourcepub fn route_handle(&self) -> RouteHandle
pub fn route_handle(&self) -> RouteHandle
Full route handle retained from ingress.
Sourcepub fn mark_binary_reply(&self)
pub fn mark_binary_reply(&self)
Declare this request’s terminal HandlerOutcome::Response as raw bytes,
not JSON, by setting FLAG_BINARY on its frame.
Mark a reply only when the operation’s contract defines a raw-byte reply,
never for JSON contracts such as tool results or JSON management replies.
The body is sent unchanged either way; the flag only declares that it is
not JSON, and the daemon forwards it as is. The delivered frame is still
bounded by subc_protocol::MAX_DELIVERED_FRAME_LEN, including its header.
All clones of this request’s context share the mark; other requests do not.
It has no effect on errors, interim stream frames, or Streamed outcomes.
Sourcepub async fn emit(&self, body: Vec<u8>) -> Result<(), SubcModuleError>
pub async fn emit(&self, body: Vec<u8>) -> Result<(), SubcModuleError>
Emit an interim StreamData frame on this request’s (channel, corr). Once
the request is cancelled or its route is gone, late emits are dropped.
Sourcepub async fn emit_with_admission(
&self,
body: Vec<u8>,
admission_class: Option<AdmissionClass>,
) -> Result<(), SubcModuleError>
pub async fn emit_with_admission( &self, body: Vec<u8>, admission_class: Option<AdmissionClass>, ) -> Result<(), SubcModuleError>
Emit StreamData with an explicit admission class. None means NORMAL.
Sourcepub fn cancelled(&self) -> WaitForCancellationFuture<'_> ⓘ
pub fn cancelled(&self) -> WaitForCancellationFuture<'_> ⓘ
Completes when the other side sends Cancel for this request or the route is torn down.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Return a cloneable cancellation token for code that prefers token polling.