pub struct PermissionSet { /* private fields */ }Expand description
A set of permissions for various resources
Implementations§
Source§impl PermissionSet
impl PermissionSet
Sourcepub fn from_permissions(perms: Vec<(Permission, ResourceType)>) -> Self
pub fn from_permissions(perms: Vec<(Permission, ResourceType)>) -> Self
Create a permission set from a list of permissions
Sourcepub fn standard_user() -> Self
pub fn standard_user() -> Self
Create a standard user permission set
Sourcepub fn add(&mut self, permission: Permission, resource: ResourceType)
pub fn add(&mut self, permission: Permission, resource: ResourceType)
Add a permission
Sourcepub fn remove(&mut self, permission: Permission, resource: ResourceType)
pub fn remove(&mut self, permission: Permission, resource: ResourceType)
Remove a permission
Sourcepub fn has_permission(
&self,
permission: Permission,
resource: ResourceType,
) -> bool
pub fn has_permission( &self, permission: Permission, resource: ResourceType, ) -> bool
Check if a permission exists
Sourcepub fn merge(&mut self, other: &PermissionSet)
pub fn merge(&mut self, other: &PermissionSet)
Merge another permission set into this one
Sourcepub fn to_vec(&self) -> Vec<(Permission, ResourceType)>
pub fn to_vec(&self) -> Vec<(Permission, ResourceType)>
Get all permissions as a vector
Trait Implementations§
Source§impl Clone for PermissionSet
impl Clone for PermissionSet
Source§fn clone(&self) -> PermissionSet
fn clone(&self) -> PermissionSet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PermissionSet
impl Debug for PermissionSet
Source§impl Default for PermissionSet
impl Default for PermissionSet
Source§fn default() -> PermissionSet
fn default() -> PermissionSet
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for PermissionSet
impl<'de> Deserialize<'de> for PermissionSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreCreates a shared type from an unshared type.