Skip to main content

RpcClientStreamingHandler

Trait RpcClientStreamingHandler 

Source
pub trait RpcClientStreamingHandler:
    Send
    + Sync
    + 'static {
    // Required method
    fn call<'life0, 'async_trait>(
        &'life0 self,
        ctx: RpcStreamingContext,
        requests: RequestStream,
    ) -> Pin<Box<dyn Future<Output = Result<RpcResponsePayload, RpcHandlerError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

User-supplied handler for a client-streaming RPC. Receives an RpcStreamingContext (caller identity, deadline, cancellation, trace context, initial REQUEST headers) plus a RequestStream of chunk bodies. Returns one terminal RpcResponsePayload — the fold publishes it as the call’s single RESPONSE frame.

Cancellation contract. Long-running handlers should select! on ctx.cancellation.cancelled() so a caller-side drop / deadline correctly stops the handler. The request stream also terminates on cancellation (yields None), but the token is the authoritative signal — the stream’s None is shared with the clean REQUEST_END path, so handlers can’t distinguish “caller finished cleanly” from “caller cancelled” without consulting the token.

Auto-grant. When the caller opted into request-direction flow control via HEADER_NRPC_REQUEST_WINDOW_INITIAL, every stream.next().await that yields Some fires one REQUEST_GRANT back to the caller, maintaining the in-flight window at the caller’s initial value. Handlers don’t need to think about credit management for the common case.

Bidi streaming plan (Phase B).

Required Methods§

Source

fn call<'life0, 'async_trait>( &'life0 self, ctx: RpcStreamingContext, requests: RequestStream, ) -> Pin<Box<dyn Future<Output = Result<RpcResponsePayload, RpcHandlerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process a client-streaming call. Drain the request stream, produce one terminal response payload (or an RpcHandlerError for failure mapping).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§