pub struct CDPClient { /* private fields */ }Expand description
Core CDP client that manages WebSocket connection and message routing
Implementations§
Source§impl CDPClient
impl CDPClient
Sourcepub async fn set_sink(&self, sink: WebSocketSink)
pub async fn set_sink(&self, sink: WebSocketSink)
Set the WebSocket sink (called from Connection)
Sourcepub async fn connect(
&self,
) -> Result<WebSocketStream<MaybeTlsStream<TcpStream>>>
pub async fn connect( &self, ) -> Result<WebSocketStream<MaybeTlsStream<TcpStream>>>
Connect to the Chrome DevTools Protocol WebSocket
Sourcepub fn subscribe_events(&self) -> Receiver<CDPMessage>
pub fn subscribe_events(&self) -> Receiver<CDPMessage>
Subscribe to all CDP events (unfiltered broadcast receiver).
Callers are responsible for filtering by msg.method and
msg.session_id as needed.
IMPORTANT: Subscribe before sending the CDP command that triggers the event to avoid the race where Chrome replies before the receiver is registered.
Sourcepub async fn send_command(
&self,
method: String,
params: Option<Value>,
) -> Result<Value>
pub async fn send_command( &self, method: String, params: Option<Value>, ) -> Result<Value>
Send a command and wait for response with timeout.
The response handler is registered before the message is sent so that fast Chrome replies are never dropped.
Sourcepub async fn send_command_with_session(
&self,
session_id: &str,
method: String,
params: Option<Value>,
) -> Result<Value>
pub async fn send_command_with_session( &self, session_id: &str, method: String, params: Option<Value>, ) -> Result<Value>
Send a command to a specific page session.
The response handler is registered before the message is sent.
Sourcepub async fn register_response_handler(&self, id: u32, tx: Sender<Value>)
pub async fn register_response_handler(&self, id: u32, tx: Sender<Value>)
Register a pending response handler
Sourcepub async fn handle_message(&self, msg: CDPMessage) -> Result<()>
pub async fn handle_message(&self, msg: CDPMessage) -> Result<()>
Handle an incoming CDP message — called by Connection
Auto Trait Implementations§
impl Freeze for CDPClient
impl !RefUnwindSafe for CDPClient
impl Send for CDPClient
impl Sync for CDPClient
impl Unpin for CDPClient
impl UnsafeUnpin for CDPClient
impl !UnwindSafe for CDPClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more