pub trait Plugin: Send + Sync {
// Required methods
fn manifest(&self) -> &PluginManifest;
fn activate(
&self,
host: &mut dyn HostContext,
plugin_root: &Path,
) -> PluginResult<()>;
fn on_action(
&self,
action_id: &str,
host: &mut dyn HostContext,
plugin_root: &Path,
) -> PluginResult<()>;
// Provided methods
fn on_undo(
&self,
_host: &mut dyn HostContext,
_plugin_root: &Path,
) -> PluginResult<()> { ... }
fn on_redo(
&self,
_host: &mut dyn HostContext,
_plugin_root: &Path,
) -> PluginResult<()> { ... }
}Expand description
The core trait that every plugin must implement.
Required Methods§
Sourcefn manifest(&self) -> &PluginManifest
fn manifest(&self) -> &PluginManifest
Return the parsed manifest for this plugin.
Sourcefn activate(
&self,
host: &mut dyn HostContext,
plugin_root: &Path,
) -> PluginResult<()>
fn activate( &self, host: &mut dyn HostContext, plugin_root: &Path, ) -> PluginResult<()>
Called once during startup. The plugin should register toolbar buttons
and any other contributions via host. plugin_root is the absolute
path to the plugin directory on disk.
Sourcefn on_action(
&self,
action_id: &str,
host: &mut dyn HostContext,
plugin_root: &Path,
) -> PluginResult<()>
fn on_action( &self, action_id: &str, host: &mut dyn HostContext, plugin_root: &Path, ) -> PluginResult<()>
Called when a toolbar button registered by this plugin is clicked.
action_id corresponds to ToolbarButtonRegistration::action_id.
plugin_root is the absolute path to the plugin directory on disk.
Provided Methods§
Sourcefn on_undo(
&self,
_host: &mut dyn HostContext,
_plugin_root: &Path,
) -> PluginResult<()>
fn on_undo( &self, _host: &mut dyn HostContext, _plugin_root: &Path, ) -> PluginResult<()>
Called when the host dispatches an undo request to this plugin.
Sourcefn on_redo(
&self,
_host: &mut dyn HostContext,
_plugin_root: &Path,
) -> PluginResult<()>
fn on_redo( &self, _host: &mut dyn HostContext, _plugin_root: &Path, ) -> PluginResult<()>
Called when the host dispatches a redo request to this plugin.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".