pub struct PermissionManager { /* private fields */ }
Expand description
Permission manager for evaluating and enforcing permissions
Implementations§
Source§impl PermissionManager
impl PermissionManager
Sourcepub fn new(default_level: PermissionLevel) -> Self
pub fn new(default_level: PermissionLevel) -> Self
Create a new permission manager
Sourcepub fn add_permission(
&mut self,
resource: String,
operation: String,
permission: Permission,
)
pub fn add_permission( &mut self, resource: String, operation: String, permission: Permission, )
Add a permission rule for a resource and operation
Sourcepub fn set_user_permission(
&mut self,
user_id: String,
resource: String,
level: PermissionLevel,
)
pub fn set_user_permission( &mut self, user_id: String, resource: String, level: PermissionLevel, )
Set user-specific permission level for a resource
Sourcepub fn add_global_constraint(&mut self, constraint: PermissionConstraint)
pub fn add_global_constraint(&mut self, constraint: PermissionConstraint)
Add a global constraint
Sourcepub fn check_permission(&self, context: &PermissionContext) -> Result<bool>
pub fn check_permission(&self, context: &PermissionContext) -> Result<bool>
Check if an operation is permitted
Sourcepub fn enforce_permission(&self, context: &PermissionContext) -> Result<()>
pub fn enforce_permission(&self, context: &PermissionContext) -> Result<()>
Enforce permission (returns error if not permitted)
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a permission manager with common defaults
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PermissionManager
impl RefUnwindSafe for PermissionManager
impl Send for PermissionManager
impl Sync for PermissionManager
impl Unpin for PermissionManager
impl UnwindSafe for PermissionManager
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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