pub struct RoleRegistry { /* private fields */ }Expand description
Bidirectional mapping of role ids to RoleSpecs plus an assignment
table tracking each member’s current role.
Implementations§
Source§impl RoleRegistry
impl RoleRegistry
Sourcepub fn define(&mut self, spec: RoleSpec)
pub fn define(&mut self, spec: RoleSpec)
Registers a role. Replaces any existing role with the same id.
Sourcepub fn define_role(
&mut self,
id: u32,
name: impl Into<String>,
permissions: Permissions,
)
pub fn define_role( &mut self, id: u32, name: impl Into<String>, permissions: Permissions, )
Convenience: defines a role from primitive components.
Sourcepub fn assign(
&mut self,
member: MemberId,
role_id: u32,
) -> Result<(), RoleError>
pub fn assign( &mut self, member: MemberId, role_id: u32, ) -> Result<(), RoleError>
Assigns a role to a member.
Sourcepub fn role_of(&self, member: MemberId) -> Option<&RoleSpec>
pub fn role_of(&self, member: MemberId) -> Option<&RoleSpec>
Returns the role currently assigned to member, if any.
Sourcepub fn permissions_of(&self, member: MemberId) -> Permissions
pub fn permissions_of(&self, member: MemberId) -> Permissions
Returns the effective permissions of member (zero if no role is
assigned).
Trait Implementations§
Source§impl Default for RoleRegistry
impl Default for RoleRegistry
Source§fn default() -> RoleRegistry
fn default() -> RoleRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RoleRegistry
impl RefUnwindSafe for RoleRegistry
impl Send for RoleRegistry
impl Sync for RoleRegistry
impl Unpin for RoleRegistry
impl UnsafeUnpin for RoleRegistry
impl UnwindSafe for RoleRegistry
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
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more