Skip to main content

BrowserBackend

Trait BrowserBackend 

Source
pub trait BrowserBackend: Send + Sync {
    // Required method
    fn fetch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        url: &'life1 Url,
        headers: &'life2 BTreeMap<String, String>,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<RenderedPage>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Abstraction over a real browser. Implemented by LocalBackend and BrowserbaseBackend.

Backends are reused across many fetches for the lifetime of a scan — they own a long-lived chromiumoxide::Browser internally. Drop the backend to release the underlying resources (kill the local process or close the remote session).

Required Methods§

Source

fn fetch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, url: &'life1 Url, headers: &'life2 BTreeMap<String, String>, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<RenderedPage>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Render url and return the final page state.

headers are applied to every request the page issues (sent via Network.setExtraHTTPHeaders before navigation). The map is keyed by header name; empty means “no overrides, use defaults”. Used by sites whose JSON APIs require app-id or custom UA — e.g. Instagram’s web_profile_info endpoint needs X-IG-App-ID.

Failures (timeout, navigation error, JS crash, etc.) should be returned as Err; the caller will convert them into a per-site Uncertain verdict so a single flaky site can’t abort the scan.

§Errors

Returns Error::BrowserSetup on connection / lifecycle problems and a generic browser error string on per-fetch failures.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§