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.
If a link, template or static policy with this ID already exists, this will error.
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
If a link, template or static policy with this ID already exists, this will error.
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 both static and template-linked 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 num_of_policies(&self) -> usize
pub fn num_of_policies(&self) -> usize
Returns the number of Policy
s in the PolicySet
.
This will include both static and template-linked policies.
sourcepub fn num_of_templates(&self) -> usize
pub fn num_of_templates(&self) -> usize
Returns the number of Template
s in the PolicySet
.
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 If a link, template or static policy with this ID already exists, this will error.
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.
source§type Err = ParseErrors
type Err = ParseErrors
impl Eq for PolicySet
Auto Trait Implementations§
impl Freeze for PolicySet
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more