pub struct BrowserConfig {Show 15 fields
pub chrome_path: Option<PathBuf>,
pub args: Vec<String>,
pub headless: bool,
pub user_data_dir: Option<PathBuf>,
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 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.
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.
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 moreSource§impl Debug for BrowserConfig
impl Debug for BrowserConfig
Source§impl Default for BrowserConfig
impl Default for BrowserConfig
Source§impl<'de> Deserialize<'de> for BrowserConfig
impl<'de> Deserialize<'de> for BrowserConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for BrowserConfig
impl RefUnwindSafe for BrowserConfig
impl Send for BrowserConfig
impl Sync for BrowserConfig
impl Unpin for BrowserConfig
impl UnsafeUnpin for BrowserConfig
impl UnwindSafe for BrowserConfig
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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