pub trait SlipstreamPlugin:
Any
+ Send
+ Sync
+ Debug {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn on_load(&mut self, _config_file: &str, _is_reload: bool) -> Result<()> { ... }
fn on_unload(&mut self) { ... }
fn subscribed_events(&self) -> &[BroadcastEventKind] { ... }
fn on_broadcast(&self, _event: BroadcastEvent<'_>) -> Result<()> { ... }
}Expand description
The interface for Aleo Slipstream plugins. A plugin must implement
the SlipstreamPlugin trait to work with the runtime. In addition,
the dynamic library must export a C function _create_plugin that
creates the implementation of the plugin.
Required Methods§
Provided Methods§
Sourcefn on_load(&mut self, _config_file: &str, _is_reload: bool) -> Result<()>
fn on_load(&mut self, _config_file: &str, _is_reload: bool) -> Result<()>
The callback called when a plugin is loaded by the system, used for
doing whatever initialization is required by the plugin. The
_config_file contains the name of the config file (JSON format) with
a libpath field indicating the full path of the shared library.
Sourcefn on_unload(&mut self)
fn on_unload(&mut self)
The callback called right before a plugin is unloaded by the system. Used for doing cleanup before unload.
Sourcefn subscribed_events(&self) -> &[BroadcastEventKind]
fn subscribed_events(&self) -> &[BroadcastEventKind]
Returns the event kinds this plugin subscribes to.
The manager checks this before serializing and dispatching each event, so plugins that return an empty slice pay no serialization cost. Defaults to no subscriptions.
Sourcefn on_broadcast(&self, _event: BroadcastEvent<'_>) -> Result<()>
fn on_broadcast(&self, _event: BroadcastEvent<'_>) -> Result<()>
Receives a single broadcast event from the plugin manager.
Only invoked when the event’s kind appears in [subscribed_events].
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".