pub trait Plugin {
// Provided method
fn routes(&self) -> Router { ... }
}Expand description
A bundle of routes a crate contributes to an app’s router - Larust’s
answer to “package/plugin system,” the last unshipped item from the
project’s own original v0.3 roadmap. Not a runtime registry (there’s no
way to justify one for a compiled language with no dynamic loading, and
this codebase already repeatedly rejects that shape elsewhere - see
Policy<U>/authorize()’s own stance against a Gate-style registry,
and larust-socialite’s doc comment explicitly disclaiming an
extend()-style provider registry). Any crate, first-party or
third-party, implements this for its own type and hands it to
Router::plugin; the compiler verifies the whole thing at the call
site.
The default routes() returns an empty Router rather than being a
required method - same defaulting precedent WireComponent::call sets
(see its own doc comment in larust-live): a plugin type with nothing
to contribute yet (middleware- or config-only, if those ever land)
shouldn’t need a no-op override just to satisfy this trait.
v1 is deliberately routes-only - no middleware, config, migration, or
scheduled-task contribution. Migrations in particular aren’t a gap:
every existing crate that needs a table already self-bootstraps it lazily
(larust-permissions’s ensure_tables(), larust-sanctum’s
ensure_table()) with no boot-time call needed at all. See
docs/ARCHITECTURE.md’s “Plugins” section for the full design and the
stated v1 boundaries.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".