pub struct RoleTable { /* private fields */ }Expand description
An in-memory Roles: each role an explicit list of grants, where an
entry may also name an earlier role (inclusion, flattened when defined).
ADMIN is built in.
use plexus_auth_core::grants::{Grant, RoleTable, Roles};
use plexus_auth_core::RoleName;
let roles = RoleTable::new()
.define("viewer", ["tickets.get", "tickets.list"]).unwrap()
.define("editor", ["viewer", "tickets.set_status"]).unwrap();
let editor = roles.grants(&RoleName::new("editor")).unwrap();
assert!(editor.contains(&Grant::new("tickets.get")));Implementations§
Source§impl RoleTable
impl RoleTable
Sourcepub fn define<I, S>(
self,
role: &str,
entries: I,
) -> Result<Self, RoleTableError>
pub fn define<I, S>( self, role: &str, entries: I, ) -> Result<Self, RoleTableError>
Define (or extend) role: each entry a grant (dotted) or an earlier
role (bare), whose grants are included. Defining a role again adds to
it, which is how several activations’ defaults for one role name
merge.
Sourcepub fn set(&mut self, role: &str, grants: GrantSet)
pub fn set(&mut self, role: &str, grants: GrantSet)
Replace role’s grants outright (an admin’s edit: the store wins).
Sourcepub fn from_lists<'a, I, G>(lists: I) -> Self
pub fn from_lists<'a, I, G>(lists: I) -> Self
A table from already-flat lists (role → [grant, …]), as a schema’s
roles carries them; lists for one role name merge.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RoleTable
impl RefUnwindSafe for RoleTable
impl Send for RoleTable
impl Sync for RoleTable
impl Unpin for RoleTable
impl UnsafeUnpin for RoleTable
impl UnwindSafe for RoleTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more