pub struct RoleSystem<S = MemoryStorage>where
S: Storage,{ /* private fields */ }Expand description
The main role-based access control system.
Implementations§
Source§impl RoleSystem<MemoryStorage>
impl RoleSystem<MemoryStorage>
Sourcepub fn with_config(config: RoleSystemConfig) -> Self
pub fn with_config(config: RoleSystemConfig) -> Self
Create a new role system with custom configuration and memory storage.
Source§impl<S> RoleSystem<S>where
S: Storage,
impl<S> RoleSystem<S>where
S: Storage,
Sourcepub fn with_storage(storage: S, config: RoleSystemConfig) -> Self
pub fn with_storage(storage: S, config: RoleSystemConfig) -> Self
Create a new role system with custom storage.
Sourcepub fn register_role(&mut self, role: Role) -> Result<()>
pub fn register_role(&mut self, role: Role) -> Result<()>
Register a new role in the system.
Sourcepub fn update_role(&mut self, role: Role) -> Result<()>
pub fn update_role(&mut self, role: Role) -> Result<()>
Update an existing role.
Sourcepub fn add_role_inheritance(&mut self, child: &str, parent: &str) -> Result<()>
pub fn add_role_inheritance(&mut self, child: &str, parent: &str) -> Result<()>
Add role inheritance (child inherits from parent).
Sourcepub fn remove_role_inheritance(
&mut self,
child: &str,
parent: &str,
) -> Result<()>
pub fn remove_role_inheritance( &mut self, child: &str, parent: &str, ) -> Result<()>
Remove role inheritance.
Sourcepub fn assign_role(&mut self, subject: &Subject, role_name: &str) -> Result<()>
pub fn assign_role(&mut self, subject: &Subject, role_name: &str) -> Result<()>
Assign a role to a subject.
Sourcepub fn remove_role(&mut self, subject: &Subject, role_name: &str) -> Result<()>
pub fn remove_role(&mut self, subject: &Subject, role_name: &str) -> Result<()>
Remove a role from a subject.
Sourcepub fn elevate_role(
&mut self,
subject: &Subject,
role_name: &str,
duration: Option<Duration>,
) -> Result<()>
pub fn elevate_role( &mut self, subject: &Subject, role_name: &str, duration: Option<Duration>, ) -> Result<()>
Temporarily elevate a subject’s role.
Sourcepub fn check_permission(
&self,
subject: &Subject,
action: &str,
resource: &Resource,
) -> Result<bool>
pub fn check_permission( &self, subject: &Subject, action: &str, resource: &Resource, ) -> Result<bool>
Check if a subject has a specific permission on a resource.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for RoleSystem<S>where
S: Freeze,
impl<S = MemoryStorage> !RefUnwindSafe for RoleSystem<S>
impl<S> Send for RoleSystem<S>
impl<S> Sync for RoleSystem<S>
impl<S> Unpin for RoleSystem<S>where
S: Unpin,
impl<S> UnwindSafe for RoleSystem<S>where
S: UnwindSafe,
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