Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required method
    fn metadata(&self) -> &PluginMetadata;

    // Provided methods
    fn init<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn shutdown<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Core plugin trait that all plugins must implement

Required Methods§

Source

fn metadata(&self) -> &PluginMetadata

Get plugin metadata

Provided Methods§

Source

fn init<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Initialize the plugin

Called once when the plugin is loaded. Use this to:

  • Validate configuration
  • Initialize resources
  • Register capabilities
Source

fn shutdown<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Shutdown the plugin

Called when the plugin is being unloaded. Use this to:

  • Clean up resources
  • Save state
  • Disconnect from services
Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Health check for the plugin

Implementors§