Skip to main content

Trait tauri::plugin::Plugin

pub trait Plugin<R: Runtime>: Send {
    fn name(&self) -> &'static str;

    fn initialize(
        &mut self, 
        app: &AppHandle<R>, 
        config: JsonValue
    ) -> Result<()> { ... }

    fn initialization_script(&self) -> Option<String> { ... }

    fn created(&mut self, window: Window<R>) { ... }

    fn on_page_load(&mut self, window: Window<R>, payload: PageLoadPayload) { ... }

    fn extend_api(&mut self, invoke: Invoke<R>) { ... }
}

Expand description

The plugin interface.

Required methods#

fn name(&self) -> &'static str[src]#

The plugin name. Used as key on the plugin config object.

Provided methods#

fn initialize(&mut self, app: &AppHandle<R>, config: JsonValue) -> Result<()>[src]#

Initializes the plugin.

fn initialization_script(&self) -> Option<String>[src]#

The JS script to evaluate on webview initialization. The script is wrapped into its own context with (function () { /* your script here */ })();, so global variables must be assigned to window instead of implicity declared.

It’s guaranteed that this script is executed before the page is loaded.

fn created(&mut self, window: Window<R>)[src]#

Callback invoked when the webview is created.

fn on_page_load(&mut self, window: Window<R>, payload: PageLoadPayload)[src]#

Callback invoked when the webview performs a navigation to a page.

fn extend_api(&mut self, invoke: Invoke<R>)[src]#

Extend commands to crate::Builder::invoke_handler.

Implementors#