Expand description
The Plugin trait — umbral’s only extension mechanism.
Auth, sessions, admin, tasks, REST, and OpenAPI are all plugins; so
is every third-party crate that ships models, routes, or commands.
This module defines the contract, the AppContext plugins receive,
and the BuildError variants topological-sort issues surface as.
See docs/specs/02-plugin-contract.md for the eventual target
shape; this file ships the M7 v1 subset (no middleware, no commands,
no inventory auto-registration).
§The trait
ⓘ
use umbral::prelude::*;
pub struct BlogPlugin;
impl Plugin for BlogPlugin {
fn name(&self) -> &'static str { "blog" }
fn dependencies(&self) -> &'static [&'static str] { &["auth"] }
fn models(&self) -> Vec<umbral::migrate::ModelMeta> {
vec![umbral::migrate::ModelMeta::for_::<Post>()]
}
fn routes(&self) -> Router {
Router::new().route("/posts", get(list))
}
}AppBuilder::plugin(BlogPlugin) registers it; App::build()
topologically sorts the registered plugins, walks every plugin’s
routes / models / system_checks, and fires on_ready in dependency
order.
Structs§
- ApiEndpoint
- One callable endpoint a plugin advertises for service discovery.
Returned from
Plugin::api_endpointsand collected atApp::build()intocrate::migrate::registered_api_endpoints. - AppContext
- The handle plugins receive in
on_ready. - Static
Dir - One on-disk source directory a plugin contributes to the unified
static pipeline. Returned from
Plugin::static_dirs. - Static
File - One static file a plugin ships baked into its binary. Returned
from
Plugin::static_files.
Traits§
- Plugin
- The contract every umbral extension implements.
Functions§
- block_
on_ ready - Run an async future to completion from inside a synchronous
Plugin::on_readyimplementation.
Type Aliases§
- Plugin
Error - Errors a plugin’s
on_readycan return. Boxed underBuildError::PluginOnReadyso the build phase surfaces them with the plugin name attached.