pub struct Connection { /* private fields */ }Expand description
One CDP connection.
Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn connect_endpoint(
endpoint: &Endpoint,
token: Option<&str>,
) -> Result<Self, Error>
pub async fn connect_endpoint( endpoint: &Endpoint, token: Option<&str>, ) -> Result<Self, Error>
Open a CDP connection from a parsed endpoint.
Sourcepub async fn connect(
endpoint_ws_url: &str,
token: Option<&str>,
) -> Result<Self, Error>
pub async fn connect( endpoint_ws_url: &str, token: Option<&str>, ) -> Result<Self, Error>
Open a CDP connection to ws://endpoint/cdp (or wss://),
attaching the optional bearer token via the ?token_secret= query
parameter (the _secret suffix lets AFDATA redaction scrub it).
Sourcepub fn subscribe(&self) -> Receiver<CdpEvent>
pub fn subscribe(&self) -> Receiver<CdpEvent>
Subscribe to events for the lifetime of this connection.
Sourcepub async fn send<P: Serialize>(
&self,
method: &str,
params: &P,
session_id: Option<&str>,
) -> Result<Value, Error>
pub async fn send<P: Serialize>( &self, method: &str, params: &P, session_id: Option<&str>, ) -> Result<Value, Error>
Send a CDP command and await the result. session_id is Some when
the call is scoped to a flattened session (after Target.attachToTarget).
Sourcepub async fn send_timeout<P: Serialize>(
&self,
method: &str,
params: &P,
session_id: Option<&str>,
timeout: Duration,
) -> Result<Value, Error>
pub async fn send_timeout<P: Serialize>( &self, method: &str, params: &P, session_id: Option<&str>, timeout: Duration, ) -> Result<Value, Error>
Send a CDP command and fail with cdp_timeout if the browser does not
answer within timeout. Unlike wrapping Self::send externally, this
removes the pending reply slot on timeout.
Sourcepub async fn wait_event<F>(
&self,
timeout: Duration,
predicate: F,
) -> Result<CdpEvent, Error>
pub async fn wait_event<F>( &self, timeout: Duration, predicate: F, ) -> Result<CdpEvent, Error>
Wait for a CDP event matching predicate (true = matches).
Returns cdp_timeout if timeout elapses first.
pub fn close(&self)
Trait Implementations§
Source§impl Drop for Connection
impl Drop for Connection
Auto Trait Implementations§
impl !Freeze for Connection
impl !RefUnwindSafe for Connection
impl !UnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
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
Mutably borrows from an owned value. Read more