BrowserConfig

Struct BrowserConfig 

Source
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: bool

Run 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: HeadlessMode

Which 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: bool

Attach 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: WebRtcConfig

WebRTC IP-leak prevention and geolocation consistency settings.

Only active when the stealth feature is enabled.

§stealth_level: StealthLevel

Anti-detection intensity level.

§disable_sandbox: bool

Disable 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: CdpFixMode

CDP 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: PoolConfig

Browser pool settings.

§launch_timeout: Duration

Browser launch timeout.

Env: STYGIAN_LAUNCH_TIMEOUT_SECS (default: 10)

§cdp_timeout: Duration

Per-operation CDP timeout.

Env: STYGIAN_CDP_TIMEOUT_SECS (default: 30)

Implementations§

Source§

impl BrowserConfig

Source

pub fn builder() -> BrowserConfigBuilder

Create a configuration builder with defaults pre-populated.

Source

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.

Source

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());
Source

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"));
Source

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);
Source

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

Source§

fn clone(&self) -> BrowserConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BrowserConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BrowserConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BrowserConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BrowserConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,