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§
Provided Methods§
Sourcefn on_event(&self, event: HostEvent) -> Result<(), String>
fn on_event(&self, event: HostEvent) -> Result<(), String>
Handles an event. A returned error is shown to the user as a
warning, as it is (translate it with tr!).
Contributes items to a viewport context menu.
Sourcefn ui_callback(
&self,
surface_id: &str,
name: &str,
args: &[Value],
) -> Result<Value, String>
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).
Sourcefn apply_filter(
&self,
filter_id: &str,
frame: &mut Frame<'_>,
) -> Result<(), String>
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.
Sourcefn open_slide(
&self,
request: &SlideOpenRequest,
) -> Result<Box<dyn SlideReader>, String>
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. A panic stops the plugin. An error says why the slide did not
open, in English, as eov’s own readers say it: eov writes it to its
log, returns it to scripts, and shows it to the user inside its own,
translated message (do not translate it, or crate::i18n::isolate
values in it).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".