pub struct PermissionSet { /* private fields */ }Expand description
A collection of permissions with utility methods.
Implementations§
Source§impl PermissionSet
impl PermissionSet
Sourcepub fn add(&mut self, permission: Permission)
pub fn add(&mut self, permission: Permission)
Add a permission to the set.
Sourcepub fn remove(&mut self, permission: &Permission)
pub fn remove(&mut self, permission: &Permission)
Remove a permission from the set.
Sourcepub fn contains(&self, permission: &Permission) -> bool
pub fn contains(&self, permission: &Permission) -> bool
Check if the set contains a specific permission.
Sourcepub fn grants(
&self,
action: &str,
resource_type: &str,
context: &HashMap<String, String>,
) -> bool
pub fn grants( &self, action: &str, resource_type: &str, context: &HashMap<String, String>, ) -> bool
Check if any permission in the set grants the given action on the resource type.
Sourcepub fn grants_with_instance(
&self,
action: &str,
resource_type: &str,
instance: Option<&str>,
context: &HashMap<String, String>,
) -> bool
pub fn grants_with_instance( &self, action: &str, resource_type: &str, instance: Option<&str>, context: &HashMap<String, String>, ) -> bool
Check if any permission in the set grants the given action on the resource type and instance.
Sourcepub fn implies(&self, permission: &Permission) -> bool
pub fn implies(&self, permission: &Permission) -> bool
Check if any permission in the set implies the given permission.
Sourcepub fn permissions(&self) -> &[Permission]
pub fn permissions(&self) -> &[Permission]
Get all permissions in the set.
Sourcepub fn merge(&mut self, other: PermissionSet)
pub fn merge(&mut self, other: PermissionSet)
Merge another permission set into this one.
Trait Implementations§
Source§impl Clone for PermissionSet
impl Clone for PermissionSet
Source§impl Debug for PermissionSet
impl Debug for PermissionSet
Source§impl Default for PermissionSet
impl Default for PermissionSet
Source§impl From<Permission> for PermissionSet
impl From<Permission> for PermissionSet
Source§fn from(permission: Permission) -> Self
fn from(permission: Permission) -> Self
Converts to this type from the input type.
Source§impl From<Vec<Permission>> for PermissionSet
impl From<Vec<Permission>> for PermissionSet
Source§fn from(permissions: Vec<Permission>) -> Self
fn from(permissions: Vec<Permission>) -> Self
Converts to this type from the input type.
Source§impl<'a> IntoIterator for &'a PermissionSet
impl<'a> IntoIterator for &'a PermissionSet
Source§impl IntoIterator for PermissionSet
impl IntoIterator for PermissionSet
Auto Trait Implementations§
impl Freeze for PermissionSet
impl !RefUnwindSafe for PermissionSet
impl Send for PermissionSet
impl Sync for PermissionSet
impl Unpin for PermissionSet
impl !UnwindSafe for PermissionSet
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