Skip to main content

Module plugin

Module plugin 

Source
Expand description

Attaching the package to an application, the way every optional package attaches itself:

ⓘ
App::new()
    .plugin(Rbac::from_config(db.clone(), &config)?)

One explicit line in main.rs, no auto-discovery. It puts a Permissions into the application context, which is where Can and req.can(...) look for it — and the only reason those two work without being handed a store.

The migrations are not registered from here, because migrations are not runtime state: they belong in the registry the CLI generates, next to the application’s own. Add them with registry.extend(rustlavel_rbac::migrations()).

Structs§

Rbac
Registers the Permissions store into application state.