playwright_cdp/playwright.rs
1//! `Playwright` — the top-level entry point (Playwright-shaped).
2//!
3//! Unlike upstream Playwright, there is **no Node.js driver** to launch. This
4//! handle exists for API-shape parity so callers coming from `playwright-rust`
5//! can write the familiar `Playwright::launch().chromium().launch(opts)`. The
6//! real engine work lives in [`BrowserType`](crate::BrowserType).
7
8use crate::browser_type::BrowserType;
9use crate::error::Result;
10
11/// The Playwright entry point. A lightweight handle — `launch()` performs no
12/// process spawning (there is no driver in this crate).
13#[derive(Debug, Clone, Copy, Default)]
14pub struct Playwright;
15
16impl Playwright {
17 /// "Launch" Playwright. No-op beyond returning a handle (no driver here).
18 pub async fn launch() -> Result<Self> {
19 Ok(Self)
20 }
21
22 /// The Chromium browser engine (the only fully-supported engine here).
23 pub fn chromium(&self) -> BrowserType {
24 BrowserType::chromium()
25 }
26
27 /// The Firefox engine. Resolves to Chromium (CDP-only crate); logs a warning on launch.
28 pub fn firefox(&self) -> BrowserType {
29 BrowserType::new(crate::browser_type::Engine::Firefox)
30 }
31
32 /// The WebKit engine. Resolves to Chromium (CDP-only crate); logs a warning on launch.
33 pub fn webkit(&self) -> BrowserType {
34 BrowserType::new(crate::browser_type::Engine::Webkit)
35 }
36}