Skip to main content

cdp_browser_lite/
lib.rs

1#![allow(missing_docs)]
2
3//! # cdp-browser-lite
4//!
5//! Total lifecycle control for Chrome instances, seamlessly integrating with `cdp-lite`.
6//!
7//! Provides the ability to spawn, attach, and manage Google Chrome or Chromium instances,
8//! ensuring correct cleanup, avoiding zombie processes, and offering a reliable interface
9//! for Headless Chrome automation.
10//!
11//! ## Example
12//!
13//! ```no_run
14//! use std::time::Duration;
15//! use cdp_browser_lite::browser::Browser;
16//! use cdp_browser_lite::config::{BrowserConfig, LaunchMode};
17//!
18//! #[tokio::main]
19//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
20//!     let config = BrowserConfig::builder()
21//!         .mode(LaunchMode::LaunchNew)
22//!         .port(0) // Ephemeral port
23//!         .headless(true)
24//!         .build();
25//!
26//!     // Launch the browser
27//!     let browser = Browser::ensure(config).await?;
28//!     let (host, port) = browser.debug_address();
29//!     println!("Chrome launched at {host}:{port}");
30//!
31//!     // Obtain a CDP client directly from the browser
32//!     let mut client = browser.client().await?;
33//!     
34//!     // Stop the browser cleanly
35//!     browser.stop().await?;
36//!     Ok(())
37//! }
38//! ```
39
40pub mod browser;
41pub mod config;
42pub mod discovery;
43pub mod error;
44pub mod ports;
45pub mod probe;
46pub mod process;
47pub mod profile;
48
49// Re-exports
50pub use browser::Browser;
51pub use cdp_lite::client::CdpClient;
52pub use cdp_lite::error::{CdpError, CdpResult};
53pub use cdp_lite::event_filter::EventFilter;
54pub use cdp_lite::protocol::{NoParams, WsCommand, WsResponse};
55pub use config::{BrowserConfig, LaunchMode, ProfileMode};
56pub use error::BrowserError;