Skip to main content

NovaPlugin

Trait NovaPlugin 

Source
pub trait NovaPlugin: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn on_init<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn extend_router(&self, router: Router<()>) -> Router<()>;

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

A plugin provides optional features to a Nova application.

Plugins should implement lifecycle hooks and may extend the application’s router to register additional routes or middleware. Plugins are loaded and initialized by NovaApp during startup.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable plugin name used in logs.

Source

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

Initialization hook called during application startup.

Source

fn extend_router(&self, router: Router<()>) -> Router<()>

Extend the provided Router<()> with plugin routes or layers.

Provided Methods§

Source

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

Shutdown hook called during application shutdown. Default is noop.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§