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> where
R: AsRef<[Identifier<'a>]>,
P: Action,
pub fn check<'a, R, P>(
&self,
resource_name: R,
action: &P
) -> Result<(), PermissionDenied> where
R: AsRef<[Identifier<'a>]>,
P: Action,
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 where
R: AsRef<[Identifier<'a>]>,
P: Action,
pub fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool where
R: AsRef<[Identifier<'a>]>,
P: Action,
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
pub fn clone(&self) -> Permissions
pub fn clone(&self) -> Permissions
Returns a copy of the value. Read more
Performs copy-assignment from source
. Read more
impl Debug for Permissions
impl Debug for Permissions
impl Default for Permissions
impl Default for Permissions
pub fn default() -> Permissions
pub fn default() -> Permissions
Returns the “default value” for a type. Read more
impl<'de> Deserialize<'de> for Permissions
impl<'de> Deserialize<'de> for Permissions
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Permissions, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub 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
Performs the conversion.
Performs the conversion.
impl From<Statement> for Permissions
impl From<Statement> for Permissions
pub fn from(stmt: Statement) -> Permissions
pub fn from(stmt: Statement) -> Permissions
Performs the conversion.
impl From<Vec<Statement, Global>> for Permissions
impl From<Vec<Statement, Global>> for Permissions
pub fn from(statements: Vec<Statement, Global>) -> Permissions
pub fn from(statements: Vec<Statement, Global>) -> Permissions
Performs the conversion.
impl Serialize for Permissions
impl Serialize for Permissions
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub 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
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more