WebBrowserAdapter

Trait WebBrowserAdapter 

Source
pub trait WebBrowserAdapter: Send + Sync {
Show 26 methods // Required methods fn connect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn disconnect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn is_connected(&self) -> bool; fn navigate<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, options: NavigateOptions, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<PageHandle>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn wait_for_load<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, timeout: Duration, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn go_back<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn go_forward<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn reload<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn extract_content<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, options: ExtractOptions, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<ExtractedContent>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn extract_links<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Vec<Link>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn extract_structured<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Value>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_html<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn capture_screenshot<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, options: CaptureOptions, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<CapturedPage>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn capture_pdf<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Vec<u8>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn click<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn type_text<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, text: &'life3 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn select_option<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, value: &'life3 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn scroll<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, x: f64, y: f64, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn wait_for_selector<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, timeout: Duration, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn evaluate_js<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, script: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Value>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn inject_script<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, script: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_cookies<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Vec<Cookie>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn set_cookie<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, cookie: Cookie, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn clear_cookies<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_local_storage<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Option<String>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn set_local_storage<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, key: &'life2 str, value: &'life3 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait;
}
Expand description

Core abstraction for web browser operations.

This trait is implemented by reasonkit-web and consumed by reasonkit-core. It provides a unified interface for web browsing, content extraction, and capture.

§Example

use reasonkit::traits::{WebBrowserAdapter, NavigateOptions, ExtractOptions};

async fn example(browser: &mut impl WebBrowserAdapter) -> WebAdapterResult<()> {
    browser.connect().await?;

    let page = browser.navigate("https://example.com", NavigateOptions::default()).await?;
    let content = browser.extract_content(&page, ExtractOptions::default()).await?;

    println!("Title: {:?}", content.title);
    println!("Word count: {}", content.word_count);

    browser.disconnect().await?;
    Ok(())
}

Required Methods§

Source

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

Connect to the browser instance.

Source

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

Disconnect from the browser instance.

Source

fn is_connected(&self) -> bool

Check if currently connected.

Source

fn navigate<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, options: NavigateOptions, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<PageHandle>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Navigate to a URL and return a handle to the loaded page.

Source

fn wait_for_load<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, timeout: Duration, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Wait for the page to finish loading.

Source

fn go_back<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Go back in browser history.

Source

fn go_forward<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Go forward in browser history.

Source

fn reload<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reload the current page.

Source

fn extract_content<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, options: ExtractOptions, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<ExtractedContent>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extract content from the page in the specified format.

Extract all links from the page.

Source

fn extract_structured<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Extract structured data using a CSS selector.

Source

fn get_html<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the raw HTML of the page.

Source

fn capture_screenshot<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, options: CaptureOptions, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<CapturedPage>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Capture a screenshot of the page.

Source

fn capture_pdf<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Capture the page as a PDF.

Source

fn click<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Click an element matching the selector.

Source

fn type_text<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, text: &'life3 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Type text into an element matching the selector.

Source

fn select_option<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, value: &'life3 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Select an option from a dropdown.

Source

fn scroll<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, x: f64, y: f64, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Scroll the page.

Source

fn wait_for_selector<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, selector: &'life2 str, timeout: Duration, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Wait for an element to appear.

Source

fn evaluate_js<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, script: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Evaluate JavaScript and return the result.

Source

fn inject_script<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, script: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Inject a script into the page.

Source

fn get_cookies<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Vec<Cookie>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all cookies for the current page.

Set a cookie.

Source

fn clear_cookies<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Clear all cookies.

Source

fn get_local_storage<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get local storage value.

Source

fn set_local_storage<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, handle: &'life1 PageHandle, key: &'life2 str, value: &'life3 str, ) -> Pin<Box<dyn Future<Output = WebAdapterResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Set local storage value.

Implementors§