Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin {
    // Required method
    fn install(self, app: &mut App);

    // Provided methods
    fn id(&self) -> &'static str { ... }
    fn requires(&self) -> &'static [&'static str] { ... }
    fn meta(&self) -> PluginMeta { ... }
}
Expand description

Single extension trait for the framework.

Prefer app.install(|app| { ... }) or app.install(Cors::new()) — application code rarely needs to name this trait; plugin authors implement it.

Required Methods§

Source

fn install(self, app: &mut App)

Register middleware, state, routes, and hooks on app.

Provided Methods§

Source

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

Stable plugin identifier used for dependency checks and crate::App::has_plugin.

Prefer a short constant ("session") over the default std::any::type_name.

Source

fn requires(&self) -> &'static [&'static str]

Required plugin ids that must be installed beforehand.

Missing deps are collected at install and reported on crate::App::build.

Source

fn meta(&self) -> PluginMeta

Display name, description, and declared PluginMeta::sdk version.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> Plugin for F
where F: FnOnce(&mut App),