pub struct CdpClient { /* private fields */ }
Expand description
Client which stores the information about which host and port to connect to.
The only purpose of this class is to get a CdpConnection
which can be used
to interact with the browser instance
Implementations§
Source§impl CdpClient
impl CdpClient
Sourcepub fn custom(host: &str, port: u16) -> Self
pub fn custom(host: &str, port: u16) -> Self
Creates a new client connecting to a custom host and port
Sourcepub fn connect_to_target(
&self,
target_id: &str,
) -> Result<CdpConnection, ClientError>
pub fn connect_to_target( &self, target_id: &str, ) -> Result<CdpConnection, ClientError>
Creates a CdpConnection
to a specifed targetId
§Examples
let client = CdpClient::new();
let cdp = client.connect_to_tab(0);
if let Ok(r) = cdp.send("Target.createTarget", parms!("url", "https://www.google.com")) {
let target_id = r["result"]["targetId"];
let cdp = client.connect_to_target(target_id);
// Use connection
}
Sourcepub fn connect_to_tab(
&self,
tab_index: usize,
) -> Result<CdpConnection, ClientError>
pub fn connect_to_tab( &self, tab_index: usize, ) -> Result<CdpConnection, ClientError>
Creates a CdpConnection
to a the tab specified by index
§Examples
let cdp = CdpClient::new().connect_to_tab(0);
// Use connection
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CdpClient
impl RefUnwindSafe for CdpClient
impl Send for CdpClient
impl Sync for CdpClient
impl Unpin 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
Mutably borrows from an owned value. Read more