Skip to main content

BidiResponder

Trait BidiResponder 

Source
pub trait BidiResponder<Req, Resp>: Send + 'static {
    // Required method
    fn respond(
        self,
        channel: Channel<'_, Req, Resp>,
    ) -> impl Future<Output = Result<(), Status>> + Send;
}
Available on crate feature server only.
Expand description

The user-driven half of a bidirectional-streaming RPC: the read-while-write loop, created by the service method (the prologue) and run after the response head is flushed.

Implement this on a type that carries whatever the prologue computed (any requests it already read, the chosen response shape, …). respond is given a Channel to interleave recv and send; trailing metadata (including grpc-status-details-bin error details) is written through Channel::response_trailers_mut and emitted with grpc-status from the returned Ok(()) / Err(Status).

Required Methods§

Source

fn respond( self, channel: Channel<'_, Req, Resp>, ) -> impl Future<Output = Result<(), Status>> + Send

Drive the bidirectional loop to completion. Ok(()) ends the RPC with grpc-status: 0; Err ends it with that status.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§