BrowserConfigBuilder

Struct BrowserConfigBuilder 

Source
pub struct BrowserConfigBuilder { /* private fields */ }
Expand description

Fluent builder for BrowserConfig.

Implementations§

Source§

impl BrowserConfigBuilder

Source

pub fn chrome_path(self, path: PathBuf) -> Self

Set path to the Chrome executable.

Source

pub fn user_data_dir(self, path: impl Into<PathBuf>) -> Self

Set a custom user profile directory.

When not set, each browser instance automatically uses a unique temporary directory derived from its instance ID, preventing SingletonLock races between concurrent pools or instances.

§Example
use stygian_browser::BrowserConfig;
let cfg = BrowserConfig::builder()
    .user_data_dir("/tmp/my-profile")
    .build();
assert!(cfg.user_data_dir.is_some());
Source

pub const fn headless(self, headless: bool) -> Self

Set headless mode.

Source

pub const fn headless_mode(self, mode: HeadlessMode) -> Self

Choose between --headless=new (default) and the legacy --headless flag.

Only relevant when headless is true. Has no effect in headed mode.

§Example
use stygian_browser::BrowserConfig;
use stygian_browser::config::HeadlessMode;
let cfg = BrowserConfig::builder()
    .headless_mode(HeadlessMode::Legacy)
    .build();
assert_eq!(cfg.headless_mode, HeadlessMode::Legacy);
Source

pub const fn window_size(self, width: u32, height: u32) -> Self

Set browser viewport / window size.

Source

pub const fn devtools(self, enabled: bool) -> Self

Enable or disable DevTools attachment.

Source

pub fn proxy(self, proxy: String) -> Self

Set proxy URL.

Source

pub fn proxy_bypass_list(self, bypass: String) -> Self

Set a comma-separated proxy bypass list.

§Example
use stygian_browser::BrowserConfig;
let cfg = BrowserConfig::builder()
    .proxy("http://proxy:8080".to_string())
    .proxy_bypass_list("<local>,localhost".to_string())
    .build();
assert!(cfg.effective_args().iter().any(|a| a.contains("proxy-bypass")));
Source

pub fn webrtc(self, webrtc: WebRtcConfig) -> Self

Set WebRTC IP-leak prevention config.

§Example
use stygian_browser::BrowserConfig;
use stygian_browser::webrtc::{WebRtcConfig, WebRtcPolicy};
let cfg = BrowserConfig::builder()
    .webrtc(WebRtcConfig { policy: WebRtcPolicy::BlockAll, ..Default::default() })
    .build();
assert!(cfg.effective_args().iter().any(|a| a.contains("disable_non_proxied")));
Source

pub fn arg(self, arg: String) -> Self

Append a custom Chrome argument.

Source

pub const fn stealth_level(self, level: StealthLevel) -> Self

Set the stealth level.

Source

pub const fn disable_sandbox(self, disable: bool) -> Self

Explicitly control whether --no-sandbox is passed to Chrome.

By default this is auto-detected: true inside containers, false on bare metal. Override only when the auto-detection is wrong.

§Example
use stygian_browser::BrowserConfig;
// Force sandbox on (bare-metal host)
let cfg = BrowserConfig::builder().disable_sandbox(false).build();
assert!(!cfg.effective_args().iter().any(|a| a == "--no-sandbox"));
Source

pub const fn cdp_fix_mode(self, mode: CdpFixMode) -> Self

Set the CDP leak-mitigation mode.

§Example
use stygian_browser::BrowserConfig;
use stygian_browser::cdp_protection::CdpFixMode;
let cfg = BrowserConfig::builder()
    .cdp_fix_mode(CdpFixMode::IsolatedWorld)
    .build();
assert_eq!(cfg.cdp_fix_mode, CdpFixMode::IsolatedWorld);
Source

pub fn source_url(self, url: Option<String>) -> Self

Override the sourceURL injected into CDP scripts, or pass None to disable sourceURL patching.

§Example
use stygian_browser::BrowserConfig;
let cfg = BrowserConfig::builder()
    .source_url(Some("main.js".to_string()))
    .build();
assert_eq!(cfg.source_url.as_deref(), Some("main.js"));
Source

pub const fn pool(self, pool: PoolConfig) -> Self

Override pool settings.

Source

pub fn build(self) -> BrowserConfig

Build the final BrowserConfig.

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> 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, 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