Struct AsyncRoleSystem

Source
pub struct AsyncRoleSystem<S>
where S: Storage + Send + Sync,
{ /* private fields */ }
Expand description

Async wrapper around the role system for non-blocking operations.

Implementations§

Source§

impl<S> AsyncRoleSystem<S>
where S: Storage + Send + Sync,

Source

pub fn new(role_system: RoleSystem<S>) -> Self

Create a new async role system.

Source

pub async fn register_role(&self, role: Role) -> Result<()>

Register a new role in the system.

Source

pub async fn get_role(&self, name: &str) -> Result<Option<Role>>

Get a role by name.

Source

pub async fn add_role_inheritance( &self, child: &str, parent: &str, ) -> Result<()>

Add role inheritance (child inherits from parent).

Source

pub async fn remove_role_inheritance( &self, child: &str, parent: &str, ) -> Result<()>

Remove role inheritance.

Source

pub async fn assign_role( &self, subject: &Subject, role_name: &str, ) -> Result<()>

Assign a role to a subject.

Source

pub async fn remove_role( &self, subject: &Subject, role_name: &str, ) -> Result<()>

Remove a role from a subject.

Source

pub async fn elevate_role( &self, subject: &Subject, role_name: &str, duration: Option<Duration>, ) -> Result<()>

Temporarily elevate a subject’s role.

Source

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.

Source

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.

Source

pub async fn get_subject_roles( &self, subject: &Subject, ) -> Result<HashSet<String>>

Get all roles assigned to a subject.

Source

pub async fn batch_check_permissions( &self, subject: &Subject, checks: &[(String, Resource)], ) -> Result<Vec<(String, Resource, bool)>>

Batch check multiple permissions for a subject.

Source

pub async fn atomic_role_operations<F, R>(&self, operations: F) -> Result<R>
where F: FnOnce(&mut RoleSystem<S>) -> Result<R> + Send,

Perform multiple role operations atomically.

Source

pub async fn with_read_access<F, R>(&self, operation: F) -> R
where F: FnOnce(&RoleSystem<S>) -> R + Send,

Get a read-only reference to the role system for complex queries.

Trait Implementations§

Source§

impl<S> Clone for AsyncRoleSystem<S>
where S: Storage + Send + Sync,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.