Trait WebSocketIo

Source
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

Required Associated Types§

Source

type Message

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn into_data(message: Self::Message) -> Bytes

Source

fn into_messsge(bytes: Bytes) -> Self::Message

Provided Methods§

Source

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.

Implementors§