Struct scratchstack_aspen::PolicySet
source · [−]pub struct PolicySet { /* private fields */ }Expand description
A set of policies being evaluated to determine the permissions in effect.
Implementations
sourceimpl PolicySet
impl PolicySet
sourcepub fn add_policy(&mut self, source: PolicySource, policy: Policy)
pub fn add_policy(&mut self, source: PolicySource, policy: Policy)
Add a policy to the set from the given source.
Example
let policy = Policy::from_str(r#"{"Statement": {"Effect": "Allow", "Action": "*", "Resource": "*"}}"#).unwrap();
let source = PolicySource::new_entity_inline("arn:aws:iam::123456789012:user/username", "AIDAEXAMPLEUSERID00", "PolicyName");
let mut policy_set = PolicySet::new();
policy_set.add_policy(source, policy);
assert_eq!(policy_set.policies().len(), 1);sourcepub fn policies(&self) -> &Vec<(PolicySource, Policy)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn policies(&self) -> &Vec<(PolicySource, Policy)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Return the policies in the policy set.
sourcepub fn evaluate<'a, 'b>(
&'a self,
context: &'b Context
) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
pub fn evaluate<'a, 'b>(
&'a self,
context: &'b Context
) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
Evaluate the policy set. If a denial is found, return a Deny and the source immediately. Otherwise, if one or more approvals are found, return Allow and the relevant sources. Otherwise, return a DefaultDeny with no sources.
sourcepub fn evaluate_all<'a, 'b>(
&'a self,
context: &'b Context
) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
pub fn evaluate_all<'a, 'b>(
&'a self,
context: &'b Context
) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
Evaluate all policies in the policy set. If one or more denials are found, return a Deny and the relevant sources. Otherwise, if one or more approvals are found, return Allow and the relevant sources. Otherwise, return a DefaultDeny with no sources.
Trait Implementations
sourceimpl From<Vec<(PolicySource, Policy), Global>> for PolicySet
impl From<Vec<(PolicySource, Policy), Global>> for PolicySet
sourcefn from(policies: Vec<(PolicySource, Policy)>) -> Self
fn from(policies: Vec<(PolicySource, Policy)>) -> Self
Converts to this type from the input type.
impl Eq for PolicySet
impl StructuralEq for PolicySet
impl StructuralPartialEq for PolicySet
Auto Trait Implementations
impl RefUnwindSafe for PolicySet
impl Send for PolicySet
impl Sync for PolicySet
impl Unpin for PolicySet
impl UnwindSafe for PolicySet
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more