pub struct CdpSession { /* private fields */ }Expand description
A live CDP WebSocket session connected to a Chrome/Chromium target.
Commands are serialized through a mutex so concurrent callers
don’t interleave frames. Responses are matched by the id field
that CDP mirrors from the request.
§Lock contention
The ws mutex is held for the entire duration of a command – from
sending the request through reading frames until the matching response
arrives. This means concurrent send_command calls will queue behind
the mutex. A per-command timeout (default 30 s, configurable via
set_timeout) bounds how long a single caller
can hold the lock, preventing indefinite blocking.
Implementations§
Source§impl CdpSession
impl CdpSession
Sourcepub async fn connect(ws_url: &str) -> Result<Self>
pub async fn connect(ws_url: &str) -> Result<Self>
Connect to a Chrome DevTools Protocol WebSocket endpoint.
Sourcepub fn set_timeout(&self, timeout: Duration)
pub fn set_timeout(&self, timeout: Duration)
Set the per-command response timeout.
Sourcepub async fn send_command(&self, method: &str, params: Value) -> Result<Value>
pub async fn send_command(&self, method: &str, params: Value) -> Result<Value>
Send a CDP command and wait for its response.
The method serializes access through a mutex, sends the JSON command
over WebSocket, then reads frames until it sees a response with a
matching id. CDP events received in the interim are logged and skipped.