pub trait WebSocketIo {
type Message;
type Error: Error + Send + Sync + 'static;
// Required methods
fn into_data(message: Self::Message) -> Bytes;
fn into_messsge(bytes: Bytes) -> Self::Message;
// Provided method
fn to_async_io(
web_socket: impl Stream<Item = Result<Self::Message, Self::Error>> + Sink<Self::Message, Error = Self::Error>,
) -> (impl AsyncRead + AsyncWrite, impl Future<Output = Result<()>>)
where Self: Sized { ... }
}Expand description
Helper to convert
- an object implementing Stream + Sink
- into an object implementing tokio::io::AsyncRead + tokio::io::AsyncWrite
Required Associated Types§
Required Methods§
fn into_data(message: Self::Message) -> Bytes
fn into_messsge(bytes: Bytes) -> Self::Message
Provided Methods§
fn to_async_io(
web_socket: impl Stream<Item = Result<Self::Message, Self::Error>> + Sink<Self::Message, Error = Self::Error>,
) -> (impl AsyncRead + AsyncWrite, impl Future<Output = Result<()>>)where
Self: Sized,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.