Skip to main content

BrowserEngine

Trait BrowserEngine 

Source
pub trait BrowserEngine: Send + Sync {
    // Required methods
    fn new_tab<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn BrowserTab>, BrowserError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_alive<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn fetch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<PageContent, BrowserError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn callback_registry(&self) -> Arc<TabCallbackRegistry>  { ... }
}
Expand description

Factory for opening and managing browser tabs.

This trait is implemented by backends (e.g. oxibrowser-core) and consumed by the tool layer via Arc<dyn BrowserEngine>.

Required Methods§

Source

fn new_tab<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn BrowserTab>, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Open a new browser tab and return it.

Source

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close all open tabs and shut down the browser instance.

Source

fn is_alive<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns true if the browser is still alive.

Provided Methods§

Source

fn fetch<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<PageContent, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch a URL and return page content (no tab management).

Source

fn callback_registry(&self) -> Arc<TabCallbackRegistry>

Access the engine’s per-tab callback registry.

Tools (e.g. BrowseTool) register per-tab callbacks keyed by tab_id. The backend’s background event-drain task extracts tab_id from each BrowserEvent and routes it to the correct callback. Backends without event streaming return an empty registry — set/invoke become no-ops.

Default implementation returns a fresh empty registry.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§