Struct bonsaidb::core::actionable::Permissions
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§
§impl Permissions
impl Permissions
pub fn allow_all() -> Permissions
pub fn allow_all() -> Permissions
Returns a Permisions
instance constructed with
Statement::allow_all()
.
pub fn check<'a, R, P>(
&self,
resource_name: R,
action: &P
) -> Result<(), PermissionDenied>
pub fn check<'a, R, P>( &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.
pub fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool
pub fn allowed_to<'a, R, P>(&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.
pub fn get<'a, 's, R>(
&'s self,
resource_name: R,
key: &str
) -> Option<&'s Configuration>where
'a: 's,
R: AsRef<[Identifier<'a>]>,
pub fn get<'a, 's, R>(
&'s self,
resource_name: R,
key: &str
) -> Option<&'s Configuration>where
'a: 's,
R: AsRef<[Identifier<'a>]>,
Looks up a configured value for resource_name
.
pub fn merged<'a>(
permissions: impl IntoIterator<Item = &'a Permissions>
) -> Permissions
pub fn merged<'a>( permissions: impl IntoIterator<Item = &'a Permissions> ) -> Permissions
Returns a new instance that merges all allowed actions from
permissions
.
Trait Implementations§
§impl Clone for Permissions
impl Clone for Permissions
§fn clone(&self) -> Permissions
fn clone(&self) -> Permissions
Returns a copy 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 more§impl Debug for Permissions
impl Debug for Permissions
§impl Default for Permissions
impl Default for Permissions
§fn default() -> Permissions
fn default() -> Permissions
Returns the “default value” for a type. Read more
§impl<'de> Deserialize<'de> for Permissions
impl<'de> Deserialize<'de> for Permissions
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Permissions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Permissions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<DefaultPermissions> for Permissions
impl From<DefaultPermissions> for Permissions
source§fn from(permissions: DefaultPermissions) -> Permissions
fn from(permissions: DefaultPermissions) -> Permissions
Converts to this type from the input type.
source§impl From<Permissions> for DefaultPermissions
impl From<Permissions> for DefaultPermissions
source§fn from(permissions: Permissions) -> DefaultPermissions
fn from(permissions: Permissions) -> DefaultPermissions
Converts to this type from the input type.
§impl From<Statement> for Permissions
impl From<Statement> for Permissions
§fn from(stmt: Statement) -> Permissions
fn from(stmt: Statement) -> Permissions
Converts to this type from the input type.
§impl From<Vec<Statement>> for Permissions
impl From<Vec<Statement>> for Permissions
§fn from(statements: Vec<Statement>) -> Permissions
fn from(statements: Vec<Statement>) -> Permissions
Converts to this type from the input type.
§impl Serialize for Permissions
impl Serialize for Permissions
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Permissions
impl Send for Permissions
impl Sync for Permissions
impl Unpin for Permissions
impl UnwindSafe for Permissions
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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