Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin:
    Send
    + Sync
    + 'static {
    // Required methods
    fn manifest(&self) -> PluginManifest;
    fn register<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ctx: &'life1 PluginContext,
        registry: &'life2 mut Registry,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A Wavyzon plugin.

use std::sync::Arc;
use wavyzon_plugin::*;

struct Hello;

#[async_trait]
impl Plugin for Hello {
    fn manifest(&self) -> PluginManifest {
        PluginManifest { name: "hello", version: "1.0.0", description: "Says hi", api_version: API_VERSION }
    }
    async fn register(&self, _ctx: &PluginContext, reg: &mut Registry) -> Result<(), PluginError> {
        reg.routes(axum::Router::new().route("/", axum::routing::get(|| async { "hi" })));
        Ok(())
    }
}

Required Methods§

Source

fn manifest(&self) -> PluginManifest

Source

fn register<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 PluginContext, registry: &'life2 mut Registry, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Register sources, filters, listeners and routes. Called once, in plugin order, before the server starts listening.

Provided Methods§

Source

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

Called once on graceful shutdown.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§