WebViewProvider

Trait WebViewProvider 

Source
pub trait WebViewProvider:
    Environment
    + Send
    + Sync {
    // Required methods
    fn CreateWebViewPanel<'life0, 'async_trait>(
        &'life0 self,
        ExtensionDataValue: Value,
        ViewType: String,
        Title: String,
        ShowOptionsValue: Value,
        PanelOptionsValue: Value,
        ContentOptionsValue: Value,
    ) -> Pin<Box<dyn Future<Output = Result<String, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn DisposeWebViewPanel<'life0, 'async_trait>(
        &'life0 self,
        Handle: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn RevealWebViewPanel<'life0, 'async_trait>(
        &'life0 self,
        Handle: String,
        ShowOptionsValue: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn SetWebViewOptions<'life0, 'async_trait>(
        &'life0 self,
        Handle: String,
        OptionsValue: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn SetWebViewHTML<'life0, 'async_trait>(
        &'life0 self,
        Handle: String,
        HTML: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn PostMessageToWebView<'life0, 'async_trait>(
        &'life0 self,
        Handle: String,
        Message: Value,
    ) -> Pin<Box<dyn Future<Output = Result<bool, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

An abstract service contract for an environment component that can manage WebView panels.

This trait defines all the operations necessary for creating WebView-based UI, setting their content, and managing their lifecycle, abstracting away the specific UI framework (e.g., Tauri, Electron) being used by the host.

Required Methods§

Source

fn CreateWebViewPanel<'life0, 'async_trait>( &'life0 self, ExtensionDataValue: Value, ViewType: String, Title: String, ShowOptionsValue: Value, PanelOptionsValue: Value, ContentOptionsValue: Value, ) -> Pin<Box<dyn Future<Output = Result<String, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a new WebView panel.

§Parameters
  • ExtensionDataValue: DTO containing information about the extension creating the panel.
  • ViewType: A unique string identifying the type of the WebView.
  • Title: The initial title for the WebView panel.
  • ShowOptionsValue: DTO specifying the view column to show the panel in.
  • PanelOptionsValue: DTO specifying behavior options for the panel (e.g., enable scripts).
  • ContentOptionsValue: DTO specifying content options (e.g., local resource roots).
§Returns

A Result containing a unique handle (string) for the new WebView, or a CommonError on failure.

Source

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

Disposes of a WebView panel, removing it from the UI.

§Parameters
  • Handle: The unique handle of the WebView panel to dispose.
Source

fn RevealWebViewPanel<'life0, 'async_trait>( &'life0 self, Handle: String, ShowOptionsValue: Value, ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reveals an existing WebView panel, bringing it to the front.

§Parameters
  • Handle: The unique handle of the WebView panel to reveal.
  • ShowOptionsValue: DTO specifying the view column to show the panel in.
Source

fn SetWebViewOptions<'life0, 'async_trait>( &'life0 self, Handle: String, OptionsValue: Value, ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets various options for a WebView panel, such as its title and icon path.

§Parameters
  • Handle: The unique handle of the WebView panel to update.
  • OptionsValue: A DTO (WebviewPanelOptionsUpdateDTO) containing the options to set.
Source

fn SetWebViewHTML<'life0, 'async_trait>( &'life0 self, Handle: String, HTML: String, ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the HTML content of a WebView panel.

  • Handle: The unique handle of the WebView panel.
  • HTML: The HTML string to set as the content.
Source

fn PostMessageToWebView<'life0, 'async_trait>( &'life0 self, Handle: String, Message: Value, ) -> Pin<Box<dyn Future<Output = Result<bool, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Posts a message from the extension host to the WebView content script.

§Parameters
  • Handle: The unique handle of the target WebView panel.
  • Message: The JSON-serializable message to post.
§Returns

Ok(true) if the message was posted successfully.

Implementors§