pub struct Permissions { /* private fields */ }Expand description
A collection of allowed permissions. This is constructed from a
Vec<Statement>. By default, no actions are allowed on any resources.
Implementations§
Source§impl Permissions
impl Permissions
Sourcepub fn allow_all() -> Self
pub fn allow_all() -> Self
Returns a Permisions instance constructed with
Statement::allow_all().
Sourcepub fn check<'a, R: AsRef<[Identifier<'a>]>, P: Action>(
&self,
resource_name: R,
action: &P,
) -> Result<(), PermissionDenied>
pub fn check<'a, R: AsRef<[Identifier<'a>]>, P: Action>( &self, resource_name: R, action: &P, ) -> Result<(), PermissionDenied>
Evaluate whether the action is allowed to be taken upon
resource_name. Returns Ok if permission is allowed.
§Errors
Returns PermissionDenied if permission is now allowed.
Sourcepub fn allowed_to<'a, R: AsRef<[Identifier<'a>]>, P: Action>(
&self,
resource_name: R,
action: &P,
) -> bool
pub fn allowed_to<'a, R: AsRef<[Identifier<'a>]>, P: Action>( &self, resource_name: R, action: &P, ) -> bool
Evaluate whether the action is allowed to be taken upon
resource_name. Returns true if the action should be allowed. If no
statements that match resource_name allow action, false will be
returned.
Sourcepub fn get<'a: 's, 's, R: AsRef<[Identifier<'a>]>>(
&'s self,
resource_name: R,
key: &str,
) -> Option<&'s Configuration>
pub fn get<'a: 's, 's, R: AsRef<[Identifier<'a>]>>( &'s self, resource_name: R, key: &str, ) -> Option<&'s Configuration>
Looks up a configured value for resource_name.
Sourcepub fn merged<'a>(permissions: impl IntoIterator<Item = &'a Self>) -> Self
pub fn merged<'a>(permissions: impl IntoIterator<Item = &'a Self>) -> Self
Returns a new instance that merges all allowed actions from
permissions.
Trait Implementations§
Source§impl Clone for Permissions
impl Clone for Permissions
Source§fn clone(&self) -> Permissions
fn clone(&self) -> Permissions
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 Permissions
impl Debug for Permissions
Source§impl Default for Permissions
impl Default for Permissions
Source§fn default() -> Permissions
fn default() -> Permissions
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for Permissions
impl<'de> Deserialize<'de> for Permissions
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
Source§impl From<Statement> for Permissions
impl From<Statement> for Permissions
Auto Trait Implementations§
impl Freeze for Permissions
impl RefUnwindSafe for Permissions
impl Send for Permissions
impl Sync for Permissions
impl Unpin for Permissions
impl UnwindSafe for Permissions
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