Skip to main content

Rbac

Struct Rbac 

Source
pub struct Rbac { /* private fields */ }
Expand description

Registers the Permissions store into application state.

Adds no routes. There is no first-party admin UI, deliberately: a screen that hands out permissions is an application’s own decision — about who may open it above all — and shipping one that is enabled by adding a plugin would be shipping a privilege-escalation route with an on switch.

Implementations§

Source§

impl Rbac

Source

pub fn new(db: Database) -> Self

The defaults: the conventional tables, super-admin, a 30-second cache.

Source

pub fn from_config(db: Database, config: &Config) -> Result<Self>

Read rbac.super_role (or rbac.super_roles) and rbac.cache_ttl_ms.

In .env that is RBAC_SUPER_ROLE=owner and RBAC_CACHE_TTL_MS=5000, through whatever mapping the application’s configuration uses.

Source

pub fn with_store(store: Permissions) -> Self

Use a store you built yourself — with different tables, say.

Source

pub fn super_role(self, name: impl Into<String>) -> Self

Source

pub fn cache_ttl(self, ttl: Duration) -> Self

Source

pub fn store(&self) -> &Permissions

The store, for wiring it into anything else that needs one.

Trait Implementations§

Source§

impl Plugin for Rbac

Source§

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

Shown by rustlavel route:list and in boot logs.
Source§

fn register(self: Box<Self>, setup: &mut Setup<'_>)

Add routes, middleware, and state.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Rbac

§

impl !UnwindSafe for Rbac

§

impl Freeze for Rbac

§

impl Send for Rbac

§

impl Sync for Rbac

§

impl Unpin for Rbac

§

impl UnsafeUnpin for Rbac

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.