Trait Plugin

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn metadata(&self) -> PluginMetadata;
    fn init<'life0, 'async_trait>(
        &'life0 mut self,
        context: PluginContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn handle_event<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        event: &'life1 Event,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn shutdown<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn handle_request<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        method: &'life1 str,
        _params: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}

Required Methods§

Source

fn id(&self) -> &str

Get the plugin’s unique ID

Source

fn metadata(&self) -> PluginMetadata

Get the plugin’s metadata

Source

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

Initialize the plugin

Source

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

Handle an event

Source

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

Shutdown the plugin

Provided Methods§

Source

fn handle_request<'life0, 'life1, 'async_trait>( &'life0 mut self, method: &'life1 str, _params: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a custom JSON-RPC request

Implementors§