Trait Plugin

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn version(&self) -> &str;
    fn capabilities(&self) -> Vec<Capability>;
    fn process<'life0, 'async_trait>(
        &'life0 self,
        request: PluginRequest,
    ) -> Pin<Box<dyn Future<Output = Result<PluginResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn description(&self) -> &str { ... }
    fn initialize<'life0, 'async_trait>(
        &'life0 mut self,
        _config: PluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn shutdown<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn can_handle(&self, _message: &Message) -> bool { ... }
    fn metadata(&self) -> PluginMetadata { ... }
}
Expand description

Plugin trait for extending bot functionality

Required Methods§

Source

fn name(&self) -> &str

Get the plugin name

Source

fn version(&self) -> &str

Get the plugin version

Source

fn capabilities(&self) -> Vec<Capability>

Get plugin capabilities

Source

fn process<'life0, 'async_trait>( &'life0 self, request: PluginRequest, ) -> Pin<Box<dyn Future<Output = Result<PluginResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process a request

Provided Methods§

Source

fn description(&self) -> &str

Get plugin description

Source

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

Initialize the plugin

Source

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

Shutdown the plugin

Source

fn can_handle(&self, _message: &Message) -> bool

Check if the plugin can handle a message

Source

fn metadata(&self) -> PluginMetadata

Get plugin metadata

Implementors§