Skip to main content

HostPlugin

Trait HostPlugin 

Source
pub trait HostPlugin: Plugin {
    // Provided methods
    fn on_task(&self, ctx: &Context) -> Result<()> { ... }
    fn on_start(&self, config: HashMap<String, String>) -> Result<()> { ... }
    fn on_stop(&self) -> Result<()> { ... }
    fn on_event(&self, event: Event) -> Result<()> { ... }
}
Expand description

The trait that all malbox host plugins implement.

All methods have default implementations, but a useful plugin should at minimum implement on_task. The #[malbox::handlers] macro generates this impl from annotated methods on your plugin struct.

Provided Methods§

Source

fn on_task(&self, ctx: &Context) -> Result<()>

Process an analysis task.

Emit results via Context::results().push(). The runtime sends a final marker automatically once this method returns.

Source

fn on_start(&self, config: HashMap<String, String>) -> Result<()>

Called once when the plugin process starts. config contains any key-value settings the daemon passes to this plugin.

Source

fn on_stop(&self) -> Result<()>

Called once when the daemon is shutting down this plugin. Use it to flush buffers, close connections, or clean up resources.

Source

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

Handle a system or plugin event.

All events (task lifecycle, plugin lifecycle, system events, and plugin result availability) are delivered through this single handler. Use #[malbox::on_event(...)] with filters in the macro to route specific events to specific methods.

Implementors§