Module web_interface

Module web_interface 

Source
Expand description

Web interface handlers and routes. Web Browser Interface Trait for ReasonKit Core

This module defines the abstraction layer for reasonkit-core to interact with reasonkit-web’s browser automation and content extraction capabilities.

§Architecture

ReasonKit Core --> WebBrowserAdapter --> ReasonKit Web
                  (trait interface)
       |- navigate()
       |- extract_content()
       `- capture_screenshot()

§Design Principles

  • Async-First: All operations use async-trait for future compatibility
  • Type-Safe: Strong types for URLs, content, and capture formats
  • Error Handling: Comprehensive error types via thiserror
  • Flexible Implementations: Support local MCP server, FFI, or HTTP bindings
  • Performance: Connection pooling and caching by default

§Example

use reasonkit::web_interface::{WebBrowserAdapter, NavigateOptions, CaptureFormat};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Implementation will use concrete adapter (e.g., McpWebAdapter, HttpWebAdapter)
    // let adapter = McpWebAdapter::new(config).await?;

    // Navigate to URL
    // let page = adapter.navigate(
    //     "https://example.com",
    //     NavigateOptions::default(),
    // ).await?;

    // Extract main content
    // let content = adapter.extract_content(
    //     &page,
    //     ExtractOptions::default(),
    // ).await?;

    // Capture screenshot
    // let screenshot = adapter.capture_screenshot(
    //     &page,
    //     CaptureOptions::default().format(CaptureFormat::Png),
    // ).await?;

    Ok(())
}

Structs§

CaptureMetadata
Capture metadata
CaptureOptions
Options for page capture/screenshot
CapturedPage
Captured page content/screenshot
ContentMetadata
Content metadata
ExtractOptions
Options for content extraction
ExtractedContent
Extracted content from a page
ExtractedImage
Extracted image from content
ExtractedLink
Extracted link from content
NavigateOptions
Options for page navigation
PageHandle
Represents a page/tab in the browser

Enums§

CaptureFormat
Screenshot/capture format
NavigateWaitEvent
Page load wait event
WebAdapterError
Web browser adapter error types

Traits§

WebBrowserAdapter
Web browser adapter trait for reasonkit-core

Type Aliases§

WebAdapterResult
Result type alias for web adapter operations