WebSocketThread

Trait WebSocketThread 

Source
pub trait WebSocketThread: Send + 'static {
    type Output: Send;

    // Required methods
    fn on_message(
        &mut self,
        message: Message,
    ) -> impl Future<Output = ()> + Send;
    fn on_close(
        &mut self,
        _clean: bool,
    ) -> impl Future<Output = Self::Output> + Send;

    // Provided method
    fn on_open(&mut self) -> impl Future<Output = ()> + Send { ... }
}
Expand description

Trait necessary to start a ws read-processing thread

Required Associated Types§

Required Methods§

Source

fn on_message(&mut self, message: Message) -> impl Future<Output = ()> + Send

On message callback

This function gets called back when a Message is received.

Source

fn on_close( &mut self, _clean: bool, ) -> impl Future<Output = Self::Output> + Send

On closed connection

This function gets called when the websockets connection is closed (either gracefully, or by an error)

Provided Methods§

Source

fn on_open(&mut self) -> impl Future<Output = ()> + Send

On opened connection

This function gets called when the websockets connection is properly stablished.

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§