Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin:
    Send
    + Sync
    + Sized
    + 'static {
    // Required method
    fn create(host: Host, init: PluginInit) -> Result<Self, String>;

    // Provided methods
    fn on_event(&self, event: HostEvent) -> Result<(), String> { ... }
    fn context_menu(&self, context: &MenuContext) -> Vec<MenuItem> { ... }
    fn ui_callback(
        &self,
        surface_id: &str,
        name: &str,
        args: &[Value],
    ) -> Result<Value, String> { ... }
    fn apply_filter(
        &self,
        filter_id: &str,
        frame: &mut Frame<'_>,
    ) -> Result<(), String> { ... }
    fn open_slide(
        &self,
        request: &SlideOpenRequest,
    ) -> Result<Box<dyn SlideReader>, String> { ... }
    fn shutdown(&self) { ... }
}
Expand description

An eov plugin.

The host calls on_event, context_menu and ui_callback on its UI thread, one at a time, with no host locks held; keep them short and move slow work to your own threads (every Host method may be called from any thread). apply_filter runs on render worker threads, possibly concurrently for different panes.

Required Methods§

Source

fn create(host: Host, init: PluginInit) -> Result<Self, String>

Creates the plugin. Keep host to call back into eov later.

Provided Methods§

Source

fn on_event(&self, event: HostEvent) -> Result<(), String>

Handles an event. Returned errors are logged and shown to the user.

Source

fn context_menu(&self, context: &MenuContext) -> Vec<MenuItem>

Contributes items to a viewport context menu.

Source

fn ui_callback( &self, surface_id: &str, name: &str, args: &[Value], ) -> Result<Value, String>

Handles a callback declared in one of the plugin’s .slint surfaces. The returned value becomes the callback’s return value (use null for callbacks without one).

Source

fn apply_filter( &self, filter_id: &str, frame: &mut Frame<'_>, ) -> Result<(), String>

Applies the CPU filter filter_id (registered with Host::register_filter) to a rendered frame in place.

Source

fn open_slide( &self, request: &SlideOpenRequest, ) -> Result<Box<dyn SlideReader>, String>

Opens a slide of one of the formats the manifest declares ([[slide_formats]]): a file whose extension, or a URI whose scheme, matched the format request.format_id.

Called on worker threads, possibly several at once, with no host locks held; it may take a while (a network round trip), but it must return. An error is shown to the user as the reason the slide did not open; a panic stops the plugin.

Source

fn shutdown(&self)

Called once before the plugin is unloaded. Stop your threads here. Slides the plugin opened may still be read (and dropped) afterwards, until eov has let go of them.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§