Skip to main content

WebviewBridge

Trait WebviewBridge 

Source
pub trait WebviewBridge: Send + Sync {
    // Required methods
    fn eval_webview(
        &self,
        label: Option<&str>,
        script: &str,
    ) -> Result<(), String>;
    fn get_window_states(&self, label: Option<&str>) -> Vec<WindowState>;
    fn list_window_labels(&self) -> Vec<String>;
    fn get_native_handle(&self, label: Option<&str>) -> Result<isize, String>;
    fn manage_window(
        &self,
        label: Option<&str>,
        action: &str,
    ) -> Result<String, String>;
    fn resize_window(
        &self,
        label: Option<&str>,
        width: u32,
        height: u32,
    ) -> Result<(), String>;
    fn move_window(
        &self,
        label: Option<&str>,
        x: i32,
        y: i32,
    ) -> Result<(), String>;
    fn set_window_title(
        &self,
        label: Option<&str>,
        title: &str,
    ) -> Result<(), String>;
}
Expand description

Runtime-erased interface for webview access, allowing the MCP server to interact with Tauri windows without generic parameters.

Required Methods§

Source

fn eval_webview(&self, label: Option<&str>, script: &str) -> Result<(), String>

Execute JavaScript in the target webview (defaults to “main” or first visible window).

Source

fn get_window_states(&self, label: Option<&str>) -> Vec<WindowState>

Retrieve the state of one or all windows (position, size, visibility, focus, URL).

Source

fn list_window_labels(&self) -> Vec<String>

Return the labels of all open webview windows.

Source

fn get_native_handle(&self, label: Option<&str>) -> Result<isize, String>

Return the platform-native window handle (HWND on Windows) for screenshot capture.

Source

fn manage_window( &self, label: Option<&str>, action: &str, ) -> Result<String, String>

Perform a window management action (minimize, maximize, close, show, hide, etc.).

Source

fn resize_window( &self, label: Option<&str>, width: u32, height: u32, ) -> Result<(), String>

Set the logical size of a window in device-independent pixels.

Source

fn move_window(&self, label: Option<&str>, x: i32, y: i32) -> Result<(), String>

Set the logical position of a window in device-independent pixels.

Source

fn set_window_title( &self, label: Option<&str>, title: &str, ) -> Result<(), String>

Set the title bar text of a window.

Implementations on Foreign Types§

Source§

impl<R: Runtime> WebviewBridge for AppHandle<R>

Source§

fn eval_webview(&self, label: Option<&str>, script: &str) -> Result<(), String>

Source§

fn get_window_states(&self, label: Option<&str>) -> Vec<WindowState>

Source§

fn list_window_labels(&self) -> Vec<String>

Source§

fn get_native_handle(&self, label: Option<&str>) -> Result<isize, String>

Source§

fn manage_window( &self, label: Option<&str>, action: &str, ) -> Result<String, String>

Source§

fn resize_window( &self, label: Option<&str>, width: u32, height: u32, ) -> Result<(), String>

Source§

fn move_window(&self, label: Option<&str>, x: i32, y: i32) -> Result<(), String>

Source§

fn set_window_title( &self, label: Option<&str>, title: &str, ) -> Result<(), String>

Implementors§