Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn meta(&self) -> PluginMeta;
    fn role(&self) -> PluginRole;
    fn start(&mut self) -> PluginResult<'_>;
    fn stop(&mut self) -> PluginResult<'_>;
    fn health(&self) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + '_>>;
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn scheduled_tasks(&self) -> Vec<ScheduledTask> { ... }
    fn setup_prompts(&self) -> Vec<SetupPrompt> { ... }
    fn tools(&self) -> Vec<Box<dyn Tool>> { ... }
}
Expand description

The core plugin contract.

Plugins are constructed via async factory functions — by the time this trait is available, the plugin is fully initialized and ready for start().

§Dyn-compatible

Uses Pin<Box<dyn Future>> for async methods. No async_trait dependency.

§Extension via as_any()

Host-specific capabilities (e.g., HTTP routes via axum) are not part of this trait. Plugins that expose such capabilities implement as_any() to allow the host to downcast to the concrete type.

Required Methods§

Source

fn meta(&self) -> PluginMeta

Plugin identity (name, version, description).

Source

fn role(&self) -> PluginRole

What role this plugin fills in the system.

Source

fn start(&mut self) -> PluginResult<'_>

Start the plugin. Called once after construction.

Source

fn stop(&mut self) -> PluginResult<'_>

Stop the plugin gracefully.

Source

fn health(&self) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + '_>>

Report current health.

Source

fn as_any(&self) -> &dyn Any

Downcast support for host-specific extensions.

Plugins that expose capabilities beyond this trait (e.g., axum routes) return self here so the host can downcast to the concrete type.

Provided Methods§

Source

fn scheduled_tasks(&self) -> Vec<ScheduledTask>

Optional: contribute scheduled tasks.

Source

fn setup_prompts(&self) -> Vec<SetupPrompt>

Optional: setup wizard prompts for first-time configuration.

Source

fn tools(&self) -> Vec<Box<dyn Tool>>

Optional: contribute tools to the pulse’s tool registry.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§