pub struct AsyncRoleSystem<S>{ /* private fields */ }Expand description
Async wrapper around the role system for non-blocking operations.
Implementations§
Source§impl<S> AsyncRoleSystem<S>
impl<S> AsyncRoleSystem<S>
Sourcepub fn new(role_system: RoleSystem<S>) -> Self
pub fn new(role_system: RoleSystem<S>) -> Self
Create a new async role system.
Sourcepub async fn register_role(&self, role: Role) -> Result<()>
pub async fn register_role(&self, role: Role) -> Result<()>
Register a new role in the system.
Sourcepub async fn add_role_inheritance(
&self,
child: &str,
parent: &str,
) -> Result<()>
pub async fn add_role_inheritance( &self, child: &str, parent: &str, ) -> Result<()>
Add role inheritance (child inherits from parent).
Sourcepub async fn remove_role_inheritance(
&self,
child: &str,
parent: &str,
) -> Result<()>
pub async fn remove_role_inheritance( &self, child: &str, parent: &str, ) -> Result<()>
Remove role inheritance.
Sourcepub async fn assign_role(
&self,
subject: &Subject,
role_name: &str,
) -> Result<()>
pub async fn assign_role( &self, subject: &Subject, role_name: &str, ) -> Result<()>
Assign a role to a subject.
Sourcepub async fn remove_role(
&self,
subject: &Subject,
role_name: &str,
) -> Result<()>
pub async fn remove_role( &self, subject: &Subject, role_name: &str, ) -> Result<()>
Remove a role from a subject.
Sourcepub async fn elevate_role(
&self,
subject: &Subject,
role_name: &str,
duration: Option<Duration>,
) -> Result<()>
pub async fn elevate_role( &self, subject: &Subject, role_name: &str, duration: Option<Duration>, ) -> Result<()>
Temporarily elevate a subject’s role.
Sourcepub async fn check_permission(
&self,
subject: &Subject,
action: &str,
resource: &Resource,
) -> Result<bool>
pub async fn check_permission( &self, subject: &Subject, action: &str, resource: &Resource, ) -> Result<bool>
Check if a subject has a specific permission on a resource.
Sourcepub async fn check_permission_with_context(
&self,
subject: &Subject,
action: &str,
resource: &Resource,
context: &HashMap<String, String>,
) -> Result<bool>
pub async fn check_permission_with_context( &self, subject: &Subject, action: &str, resource: &Resource, context: &HashMap<String, String>, ) -> Result<bool>
Check permission with additional context.
Sourcepub async fn get_subject_roles(
&self,
subject: &Subject,
) -> Result<HashSet<String>>
pub async fn get_subject_roles( &self, subject: &Subject, ) -> Result<HashSet<String>>
Get all roles assigned to a subject.
Sourcepub async fn batch_check_permissions(
&self,
subject: &Subject,
checks: &[(String, Resource)],
) -> Result<Vec<(String, Resource, bool)>>
pub async fn batch_check_permissions( &self, subject: &Subject, checks: &[(String, Resource)], ) -> Result<Vec<(String, Resource, bool)>>
Batch check multiple permissions for a subject.
Sourcepub async fn atomic_role_operations<F, R>(&self, operations: F) -> Result<R>
pub async fn atomic_role_operations<F, R>(&self, operations: F) -> Result<R>
Perform multiple role operations atomically.
Sourcepub async fn with_read_access<F, R>(&self, operation: F) -> R
pub async fn with_read_access<F, R>(&self, operation: F) -> R
Get a read-only reference to the role system for complex queries.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for AsyncRoleSystem<S>
impl<S> !RefUnwindSafe for AsyncRoleSystem<S>
impl<S> Send for AsyncRoleSystem<S>
impl<S> Sync for AsyncRoleSystem<S>
impl<S> Unpin for AsyncRoleSystem<S>
impl<S> !UnwindSafe for AsyncRoleSystem<S>
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