pub struct BrowserConfig {Show 17 fields
pub chrome_path: Option<PathBuf>,
pub args: Vec<String>,
pub headless: bool,
pub user_data_dir: Option<PathBuf>,
pub headless_mode: HeadlessMode,
pub window_size: Option<(u32, u32)>,
pub devtools: bool,
pub proxy: Option<String>,
pub proxy_bypass_list: Option<String>,
pub webrtc: WebRtcConfig,
pub stealth_level: StealthLevel,
pub disable_sandbox: bool,
pub cdp_fix_mode: CdpFixMode,
pub source_url: Option<String>,
pub pool: PoolConfig,
pub launch_timeout: Duration,
pub cdp_timeout: Duration,
}Expand description
Top-level configuration for a browser session.
§Example
use stygian_browser::BrowserConfig;
let config = BrowserConfig::builder()
.headless(true)
.window_size(1920, 1080)
.build();
assert!(config.headless);Fields§
§chrome_path: Option<PathBuf>Path to the Chrome/Chromium executable.
Env: STYGIAN_CHROME_PATH
args: Vec<String>Extra Chrome launch arguments appended after the defaults.
headless: boolRun in headless mode (no visible window).
Env: STYGIAN_HEADLESS (true/false, default: true)
user_data_dir: Option<PathBuf>Persistent user profile directory. None = temporary profile.
headless_mode: HeadlessModeWhich headless mode to use when headless is true.
Defaults to HeadlessMode::New (--headless=new).
Env: STYGIAN_HEADLESS_MODE (new/legacy)
window_size: Option<(u32, u32)>Browser window size in pixels (width, height).
devtools: boolAttach DevTools on launch (useful for debugging, disable in production).
proxy: Option<String>HTTP/SOCKS proxy URL, e.g. http://user:pass@host:port.
proxy_bypass_list: Option<String>Comma-separated list of hosts that bypass the proxy.
Env: STYGIAN_PROXY_BYPASS (e.g. "<local>,localhost,127.0.0.1")
webrtc: WebRtcConfigWebRTC IP-leak prevention and geolocation consistency settings.
Only active when the stealth feature is enabled.
stealth_level: StealthLevelAnti-detection intensity level.
disable_sandbox: boolDisable Chromium’s built-in renderer sandbox (--no-sandbox).
Chromium’s sandbox requires user namespaces, which are unavailable inside
most container runtimes. When running in Docker or similar, set this to
true (or set STYGIAN_DISABLE_SANDBOX=true) and rely on the
container’s own isolation instead.
Never set this on a bare-metal host without an alternative isolation boundary. Doing so removes a meaningful security layer.
Env: STYGIAN_DISABLE_SANDBOX (true/false, default: auto-detect)
cdp_fix_mode: CdpFixModeCDP Runtime.enable leak-mitigation mode.
Env: STYGIAN_CDP_FIX_MODE (add_binding/isolated_world/enable_disable/none)
source_url: Option<String>Source URL injected into Function.prototype.toString patches, or
None to use the default ("app.js").
Set to "0" (as a string) to disable sourceURL patching entirely.
Env: STYGIAN_SOURCE_URL
pool: PoolConfigBrowser pool settings.
launch_timeout: DurationBrowser launch timeout.
Env: STYGIAN_LAUNCH_TIMEOUT_SECS (default: 10)
cdp_timeout: DurationPer-operation CDP timeout.
Env: STYGIAN_CDP_TIMEOUT_SECS (default: 30)
Implementations§
Source§impl BrowserConfig
impl BrowserConfig
Sourcepub fn builder() -> BrowserConfigBuilder
pub fn builder() -> BrowserConfigBuilder
Create a configuration builder with defaults pre-populated.
Sourcepub fn effective_args(&self) -> Vec<String>
pub fn effective_args(&self) -> Vec<String>
Collect the effective Chrome launch arguments.
Returns the anti-detection baseline args merged with any user-supplied
extras from BrowserConfig::args.
Sourcepub fn validate(&self) -> Result<(), Vec<String>>
pub fn validate(&self) -> Result<(), Vec<String>>
Validate the configuration, returning a list of human-readable errors.
Returns Ok(()) when valid, or Err(errors) with a non-empty list.
§Example
use stygian_browser::BrowserConfig;
use stygian_browser::config::PoolConfig;
use std::time::Duration;
let mut cfg = BrowserConfig::default();
cfg.pool.min_size = 0;
cfg.pool.max_size = 0; // invalid: max must be >= 1
let errors = cfg.validate().unwrap_err();
assert!(!errors.is_empty());Sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Serialize this configuration to a JSON string.
§Errors
Returns a serde_json::Error if serialization fails (very rare).
§Example
use stygian_browser::BrowserConfig;
let cfg = BrowserConfig::default();
let json = cfg.to_json().unwrap();
assert!(json.contains("headless"));Sourcepub fn from_json_str(s: &str) -> Result<Self, Error>
pub fn from_json_str(s: &str) -> Result<Self, Error>
Deserialize a BrowserConfig from a JSON string.
Environment variable overrides will NOT be re-applied — the JSON values are used verbatim. Chain with builder methods to override individual fields after loading.
§Errors
Returns a serde_json::Error if the input is invalid JSON or has
missing required fields.
§Example
use stygian_browser::BrowserConfig;
let cfg = BrowserConfig::default();
let json = cfg.to_json().unwrap();
let back = BrowserConfig::from_json_str(&json).unwrap();
assert_eq!(back.headless, cfg.headless);Sourcepub fn from_json_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_json_file(path: impl AsRef<Path>) -> Result<Self>
Load a BrowserConfig from a JSON file on disk.
§Errors
Returns a crate::error::BrowserError::ConfigError wrapping any I/O
or parse error.
§Example
use stygian_browser::BrowserConfig;
let cfg = BrowserConfig::from_json_file("/etc/stygian/config.json").unwrap();Trait Implementations§
Source§impl Clone for BrowserConfig
impl Clone for BrowserConfig
Source§fn clone(&self) -> BrowserConfig
fn clone(&self) -> BrowserConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more