pub trait WebSocketHandler:
Send
+ Sync
+ 'static {
// Required methods
fn on_connect(&self) -> impl Future<Output = ()> + Send;
fn on_message(
&self,
message: WebSocketMessage,
) -> impl Future<Output = Result<Option<WebSocketMessage>>> + Send;
fn on_close(
&self,
code: Option<WebSocketCloseCode>,
) -> impl Future<Output = ()> + Send;
}Expand description
WebSocket connection handler
Required Methods§
Sourcefn on_connect(&self) -> impl Future<Output = ()> + Send
fn on_connect(&self) -> impl Future<Output = ()> + Send
Handle a new WebSocket connection
Sourcefn on_message(
&self,
message: WebSocketMessage,
) -> impl Future<Output = Result<Option<WebSocketMessage>>> + Send
fn on_message( &self, message: WebSocketMessage, ) -> impl Future<Output = Result<Option<WebSocketMessage>>> + Send
Handle an incoming 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.