Skip to main content

playhard_launcher/
options.rs

1use std::{ffi::OsString, path::PathBuf, time::Duration};
2
3/// The launch transport to request from Chrome.
4#[derive(Debug, Clone, Copy, Eq, PartialEq)]
5pub enum TransportMode {
6    /// Start Chrome with `--remote-debugging-port=0`.
7    WebSocket,
8    /// Start Chrome with `--remote-debugging-pipe`.
9    Pipe,
10}
11
12/// Options that control how Chrome is launched.
13#[derive(Debug, Clone, Eq, PartialEq)]
14pub struct LaunchOptions {
15    /// Optional Chrome executable path. If omitted, `chrome-locations` is used.
16    pub executable_path: Option<PathBuf>,
17    /// Optional user data directory. If omitted, a temporary one is created.
18    pub user_data_dir: Option<PathBuf>,
19    /// Launch transport to use.
20    pub transport_mode: TransportMode,
21    /// Launch Chrome headless when set.
22    pub headless: bool,
23    /// Additional Chrome command-line arguments.
24    pub args: Vec<OsString>,
25    /// How long to wait for Chrome to become ready.
26    pub startup_timeout: Duration,
27}
28
29impl Default for LaunchOptions {
30    fn default() -> Self {
31        Self {
32            executable_path: None,
33            user_data_dir: None,
34            transport_mode: TransportMode::WebSocket,
35            headless: false,
36            args: Vec::new(),
37            startup_timeout: Duration::from_secs(15),
38        }
39    }
40}