pub struct CDPSession { /* private fields */ }Expand description
Lock-free CDP session using DashMap for pending responses and events, ArcSwap for the session ID, and atomics for the ID counter.
Implementations§
Source§impl CDPSession
impl CDPSession
pub fn new(send_tx: UnboundedSender<String>, timeout_ms: u64) -> Self
Sourcepub fn handle_message(&self, data: &str) -> bool
pub fn handle_message(&self, data: &str) -> bool
Process an incoming message. Returns true if it was handled.
Sourcepub async fn send(&self, method: &str, params: Value) -> Result<Value>
pub async fn send(&self, method: &str, params: Value) -> Result<Value>
Send a browser-level CDP command.
Sourcepub async fn send_to_target(&self, method: &str, params: Value) -> Result<Value>
pub async fn send_to_target(&self, method: &str, params: Value) -> Result<Value>
Send a page-scoped CDP command.
pub fn on(&self, method: &str, handler: Arc<dyn Fn(Value) + Send + Sync>)
Sourcepub async fn attach_to_page(&self) -> Result<String>
pub async fn attach_to_page(&self) -> Result<String>
Discover/create a page target, attach, enable domains.
pub async fn capture_screenshot(&self) -> Result<String>
pub async fn get_html(&self) -> Result<String>
pub async fn evaluate(&self, expression: &str) -> Result<Value>
pub async fn click_point(&self, x: f64, y: f64) -> Result<()>
pub async fn right_click_point(&self, x: f64, y: f64) -> Result<()>
pub async fn double_click_point(&self, x: f64, y: f64) -> Result<()>
pub async fn click_hold_point(&self, x: f64, y: f64, hold_ms: u64) -> Result<()>
pub async fn hover_point(&self, x: f64, y: f64) -> Result<()>
pub async fn drag_point(&self, fx: f64, fy: f64, tx: f64, ty: f64) -> Result<()>
pub async fn insert_text(&self, text: &str) -> Result<()>
pub async fn press_key( &self, key: &str, code: &str, key_code: u32, ) -> Result<()>
pub async fn key_down(&self, key: &str, code: &str, key_code: u32) -> Result<()>
pub async fn key_up(&self, key: &str, code: &str, key_code: u32) -> Result<()>
pub async fn set_viewport( &self, w: u32, h: u32, dpr: f64, mobile: bool, ) -> Result<()>
pub fn destroy(&self)
Auto Trait Implementations§
impl !Freeze for CDPSession
impl !RefUnwindSafe for CDPSession
impl Send for CDPSession
impl Sync for CDPSession
impl Unpin for CDPSession
impl !UnwindSafe for CDPSession
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