pub trait MessageStream: Unpin + Send {
// Required methods
fn send<'life0, 'async_trait>(
&'life0 mut self,
msg: WireMessage,
) -> Pin<Box<dyn Future<Output = Result<(), StreamError>> + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<Result<WireMessage, StreamError>>> + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
An object-safe, bidirectional message channel — what the session loop consumes.
Renamed from WsStream in 2.0 (the alias below keeps old code compiling): it is
no longer WebSocket-specific. A Unix socket, a named pipe, or an XPC connection
implements this just as well, either directly or via
TransportStream.
Note ?Send: implementations’ futures need not be Send. serve_with
and the session loop poll them in place on one thread, and TCP listen
polls connections the same way, on the nagoya reactor it builds. There is
no LocalSet and nothing that needs one: the hyper upgrader whose
spawn_local used to require it is gone.
Required Methods§
fn send<'life0, 'async_trait>(
&'life0 mut self,
msg: WireMessage,
) -> Pin<Box<dyn Future<Output = Result<(), StreamError>> + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<Result<WireMessage, StreamError>>> + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".