Skip to main content

WebSocketStreamHandler

Trait WebSocketStreamHandler 

Source
pub trait WebSocketStreamHandler {
    // Required methods
    fn setup_stream(
        &mut self,
        stream: WebSocketStream<MaybeTlsStream<TcpStream>>,
    ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send;
    fn handle_message(
        &self,
        message: Message,
    ) -> impl Future<Output = Result<Option<Message>, Box<dyn Error + Send + Sync>>> + Send;
}
Expand description

Trait for types that can be used as WebSocket stream endpoints

Required Methods§

Source

fn setup_stream( &mut self, stream: WebSocketStream<MaybeTlsStream<TcpStream>>, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send

Setup the WebSocket stream

Source

fn handle_message( &self, message: Message, ) -> impl Future<Output = Result<Option<Message>, Box<dyn Error + Send + Sync>>> + Send

Handle incoming WebSocket message

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§