pub trait TransportStream: Send {
// Required method
fn recv<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<TransportEvent>, TransportError>> + Send + 'a>>;
}Expand description
The read half of a transport: yields one TransportEvent at a time, or None when
the other side closed the connection.
Required Methods§
Sourcefn recv<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<TransportEvent>, TransportError>> + Send + 'a>>
fn recv<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<TransportEvent>, TransportError>> + Send + 'a>>
Yield the next event.
Must be cancel-safe: the returned future can be dropped before it completes, and
doing so must not lose or partially consume an event - the next recv call has to pick
up where this one left off. Client’s read loop races this against an internal
“abandon this connection and redial” signal (fired by keepalive when the peer stops
answering pings), so a stalled recv gets dropped mid-poll rather than parking the loop
until the OS TCP timeout.
The two implementations in the Flowion tree satisfy this because they bottom out in
already-cancel-safe primitives (futures::StreamExt::next over a tokio-tungstenite
stream; an embassy-net socket read). An implementation that buffers partial state in a
local variable across an .await needs to move that state into self to qualify.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".