Skip to main content

SlipstreamPlugin

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§

Source

fn name(&self) -> &'static str

Returns the name of the plugin.

Provided Methods§

Source

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.

Source

fn on_unload(&mut self)

The callback called right before a plugin is unloaded by the system. Used for doing cleanup before unload.

Source

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.

Source

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".

Implementors§