pub struct CdpClient { /* private fields */ }Expand description
CDP client wrapping a shared chromiumoxide Browser.
§Interior mutability
browser uses tokio::sync::Mutex because guards are held across
.await points (Browser::execute, pages(), event_listener). A
std::sync::Mutex here would block the async runtime (rules: never hold
std mutex across .await). The mutex is not exposed in the public agent
JSON API — only as an internal handle for FINALIZE.
§Ownership
Holds the event-handler task and shared browser mutex — do not discard
without FINALIZE (#[must_use]).
Implementations§
Source§impl CdpClient
impl CdpClient
Sourcepub async fn from_browser(
browser: Browser,
handler: Handler,
) -> Result<Self, String>
pub async fn from_browser( browser: Browser, handler: Handler, ) -> Result<Self, String>
Build client from an already-launched or connected chromiumoxide Browser + handler.
Sourcepub async fn connect(url: &str) -> Result<Self, String>
pub async fn connect(url: &str) -> Result<Self, String>
Attach via chromiumoxide Browser::connect (lightpanda only).
Sourcepub async fn connect_with_headers(
url: &str,
_headers: Option<Vec<(String, String)>>,
) -> Result<Self, String>
pub async fn connect_with_headers( url: &str, _headers: Option<Vec<(String, String)>>, ) -> Result<Self, String>
Headers are ignored on the oxide path (chromiumoxide connect has no custom WS headers API).
Sourcepub fn browser(&self) -> Arc<Mutex<Browser>> ⓘ
pub fn browser(&self) -> Arc<Mutex<Browser>> ⓘ
Shared browser handle (for FINALIZE close/wait/kill).
pub async fn send_command( &self, method: &str, params: Option<Value>, session_id: Option<&str>, ) -> Result<Value, String>
pub fn subscribe(&self) -> Receiver<CdpEvent>
pub async fn send_command_typed<P: Serialize, R: DeserializeOwned>( &self, method: &str, params: &P, session_id: Option<&str>, ) -> Result<R, String>
pub async fn send_command_no_params( &self, method: &str, session_id: Option<&str>, ) -> Result<Value, String>
Source§impl CdpClient
impl CdpClient
Sourcepub async fn attach_page_console_forwarders(&self) -> Result<(), String>
pub async fn attach_page_console_forwarders(&self) -> Result<(), String>
Attach page-level console listeners (context7 pattern: page.event_listener). Complements browser-level forwarders when Runtime events are page-scoped.
Sourcepub async fn attach_page_network_forwarders(&self) -> Result<(), String>
pub async fn attach_page_network_forwarders(&self) -> Result<(), String>
Page-level Network.requestWillBeSent (page-scoped CDP events).
Sourcepub async fn attach_page_session_forwarders(&self) -> Result<(), String>
pub async fn attach_page_session_forwarders(&self) -> Result<(), String>
Page-scoped CDP events (heap chunks, screencast frames, JS dialogs). Browser-level listeners miss target-session events; attach after pages exist.
Multi-page attach is I/O-bound → [join_bounded] after releasing the
browser lock (PAR-53).
Auto Trait Implementations§
impl !RefUnwindSafe for CdpClient
impl !UnwindSafe for CdpClient
impl Freeze for CdpClient
impl Send for CdpClient
impl Sync for CdpClient
impl Unpin for CdpClient
impl UnsafeUnpin for CdpClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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