pub trait Handler: MaybeSend + 'static {
// Required method
fn message(&mut self, message: &Message<'_>);
// Provided methods
fn event(&mut self, event: Event) { ... }
fn binary(&mut self, data: &[u8]) { ... }
fn ready(&mut self) -> impl Future<Output = ()> + MaybeSend { ... }
}Expand description
What the application does with what the server sends.
The client calls it from the connection’s own task, in the order the messages came, with each message read in place from its frame. It holds the connection while it runs: hand long work to a task of its own.
A closure taking &Message is a handler too.
Required Methods§
Provided Methods§
Sourcefn ready(&mut self) -> impl Future<Output = ()> + MaybeSend
fn ready(&mut self) -> impl Future<Output = ()> + MaybeSend
Called before each frame is read once the server took the connection. Waiting here holds the server back while the application catches up; the heartbeat and sends go on meanwhile, and the wait may be dropped for them and begun again: it must lose nothing when dropped. Not called in the browser, which cannot hold a WebSocket back: there the frames wait in memory.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".