pub struct WsReader<T: EventMessage> { /* private fields */ }Expand description
Handler-facing read half of the split WebSocket connection.
Decoded CDP messages are produced by a dedicated background task
(see [ws_read_loop]) and forwarded over a bounded mpsc. WsReader
itself is a thin Receiver wrapper — calling next_message() does
a single rx.recv().await with no per-message decoding work on the
caller’s task. This keeps the Handler’s poll loop free of CPU-bound
deserialize time, which matters for large (multi-MB) CDP responses
such as screenshots and wide-header network events.
Implementations§
Source§impl<T: EventMessage + Unpin> WsReader<T>
impl<T: EventMessage + Unpin> WsReader<T>
Sourcepub async fn next_message(&mut self) -> Option<Result<Box<Message<T>>>>
pub async fn next_message(&mut self) -> Option<Result<Box<Message<T>>>>
Read the next CDP message from the WebSocket.
Returns None when the background reader task has exited
(connection closed or sender dropped). This call does only a
channel recv — the actual WS read + JSON decode happens on
the background ws_read_loop task.