Struct cedar_policy::PolicySet
source · pub struct PolicySet { /* private fields */ }
Expand description
Represents a set of Policy
s
Implementations§
source§impl PolicySet
impl PolicySet
sourcepub fn from_policies(
policies: impl IntoIterator<Item = Policy>
) -> Result<Self, PolicySetError>
pub fn from_policies( policies: impl IntoIterator<Item = Policy> ) -> Result<Self, PolicySetError>
Create a PolicySet
from the given policies
sourcepub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
pub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
Add an static policy to the PolicySet
. To add a template instance, use
link
instead. This function will return an error (and not modify
the PolicySet
) if a template-linked policy is passed in.
sourcepub fn add_template(&mut self, template: Template) -> Result<(), PolicySetError>
pub fn add_template(&mut self, template: Template) -> Result<(), PolicySetError>
Add a Template
to the PolicySet
sourcepub fn policies(&self) -> impl Iterator<Item = &Policy>
pub fn policies(&self) -> impl Iterator<Item = &Policy>
Iterate over all the Policy
s in the PolicySet
.
This will include policies that result from instantiating a template, and inline policies.
sourcepub fn templates(&self) -> impl Iterator<Item = &Template>
pub fn templates(&self) -> impl Iterator<Item = &Template>
Iterate over the Template
’s in the PolicySet
.
sourcepub fn annotation<'a>(
&'a self,
id: &PolicyId,
key: impl AsRef<str>
) -> Option<&'a str>
pub fn annotation<'a>( &'a self, id: &PolicyId, key: impl AsRef<str> ) -> Option<&'a str>
Extract annotation data from a Policy
by its PolicyId
and annotation key
sourcepub fn template_annotation(
&self,
id: &PolicyId,
key: impl AsRef<str>
) -> Option<String>
pub fn template_annotation( &self, id: &PolicyId, key: impl AsRef<str> ) -> Option<String>
Extract annotation data from a Template
by its PolicyId
and annotation key.
sourcepub fn link(
&mut self,
template_id: PolicyId,
new_id: PolicyId,
vals: HashMap<SlotId, EntityUid>
) -> Result<(), PolicySetError>
pub fn link( &mut self, template_id: PolicyId, new_id: PolicyId, vals: HashMap<SlotId, EntityUid> ) -> Result<(), PolicySetError>
Attempt to link a template and add the new template-linked policy to the policy set.
If link fails, the PolicySet
is not modified.
Failure can happen for three reasons
- The map passed in
vals
may not match the slots in the template - The
new_id
may conflict w/ a policy that already exists in the set template_id
does not correspond to a template. Either the id is not in the policy set, or it is in the policy set but is either a linked or static policy rather than a template
Trait Implementations§
source§impl FromStr for PolicySet
impl FromStr for PolicySet
source§fn from_str(policies: &str) -> Result<Self, Self::Err>
fn from_str(policies: &str) -> Result<Self, Self::Err>
Create a policy set from multiple statements.
Policy ids will default to “policy*” with numbers from 0 If you load more policies, do not use the default id, or there will be conflicts.
See Policy
for more.
§type Err = ParseErrors
type Err = ParseErrors
source§impl PartialEq<PolicySet> for PolicySet
impl PartialEq<PolicySet> for PolicySet
impl Eq 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§
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.