pub trait StreamDriver {
type Send;
type Receive;
// Required methods
fn send(&mut self, message: &Self::Send) -> Result<(), StreamError>;
fn half_close(&mut self) -> Result<(), StreamError>;
fn try_recv_next(&mut self) -> Result<Option<Self::Receive>, StreamError>;
fn wait_ready(&mut self) -> Result<(), StreamError>;
fn finish(
&mut self,
status: &Status,
trailers: &Metadata,
) -> Result<(), StreamError>;
fn initial_metadata(&self) -> Option<&Metadata>;
fn trailing_metadata(&self) -> Option<&Metadata>;
fn cancel(&mut self);
}Expand description
Typed, single-threaded transport seam for one RPC.
WouldBlock means no message, send, half-close or finish was committed; a
retry must not duplicate a frame. All methods except wait_ready are bounded
nonblocking steps. wait_ready waits for actual I/O readiness or a deadline
on the caller thread; it must not busy-spin. Errors other than WouldBlock
terminate the call. Before returning client response EOF, validate grpc-status
and expose trailers (including an empty collection); non-OK status is an error.
Request EOF on a server only half-closes its inbound direction.
Metadata remains available after cancellation. cancel releases local stream
resources without waiting, cannot panic, and does not promise peer acknowledgement.
Required Associated Types§
Required Methods§
Sourcefn send(&mut self, message: &Self::Send) -> Result<(), StreamError>
fn send(&mut self, message: &Self::Send) -> Result<(), StreamError>
Attempts to commit one outgoing message.
§Errors
Returns pending without accepting the message, or a terminal failure.
Sourcefn half_close(&mut self) -> Result<(), StreamError>
fn half_close(&mut self) -> Result<(), StreamError>
Attempts to half-close outgoing messages.
§Errors
Returns pending without closing, or a terminal failure.
Sourcefn try_recv_next(&mut self) -> Result<Option<Self::Receive>, StreamError>
fn try_recv_next(&mut self) -> Result<Option<Self::Receive>, StreamError>
Receives a message, validated EOF, or a pending/terminal error.
§Errors
Returns WouldBlock while pending; all other errors are terminal.
Sourcefn wait_ready(&mut self) -> Result<(), StreamError>
fn wait_ready(&mut self) -> Result<(), StreamError>
Waits for readiness needed by the last pending operation.
§Errors
Returns a terminal transport/deadline failure; must not return WouldBlock.
Sourcefn finish(
&mut self,
status: &Status,
trailers: &Metadata,
) -> Result<(), StreamError>
fn finish( &mut self, status: &Status, trailers: &Metadata, ) -> Result<(), StreamError>
Attempts server completion, including non-OK trailers-only responses.
§Errors
Returns pending without committing completion, or a terminal failure.
fn initial_metadata(&self) -> Option<&Metadata>
fn trailing_metadata(&self) -> Option<&Metadata>
fn cancel(&mut self)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".