Struct cedar_policy_core::ast::PolicySet
source · pub struct PolicySet { /* private fields */ }
Expand description
Represents a set of Policy
s
Implementations§
source§impl PolicySet
impl PolicySet
sourcepub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
pub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
Add a Policy
to the PolicySet
.
sourcepub fn add_static(&mut self, policy: StaticPolicy) -> Result<(), PolicySetError>
pub fn add_static(&mut self, policy: StaticPolicy) -> Result<(), PolicySetError>
Add a StaticPolicy
to the PolicySet
.
sourcepub fn add_template(&mut self, t: Template) -> Result<(), PolicySetError>
pub fn add_template(&mut self, t: Template) -> Result<(), PolicySetError>
Add a template to the policy set. If a link or template with the same name already exists, this will error.
sourcepub fn link(
&mut self,
template_id: PolicyID,
new_id: PolicyID,
values: HashMap<SlotId, EntityUID>,
) -> Result<&Policy, LinkingError>
pub fn link( &mut self, template_id: PolicyID, new_id: PolicyID, values: HashMap<SlotId, EntityUID>, ) -> Result<&Policy, LinkingError>
Attempt to create a new template linked policy and add it to the policy set. Returns a references to the new template linked policy if successful.
Errors for two reasons
- The the passed SlotEnv either does not match the slots in the templates
- The passed link Id conflicts with an Id already in the set
sourcepub fn all_templates(&self) -> impl Iterator<Item = &Template>
pub fn all_templates(&self) -> impl Iterator<Item = &Template>
Iterate over everything stored as template, including static policies. Ie: all_templates() should equal templates() ++ static_policies().map(|p| p.template())
sourcepub fn static_policies(&self) -> impl Iterator<Item = &Policy>
pub fn static_policies(&self) -> impl Iterator<Item = &Policy>
Iterate over all of the static policies.
sourcepub fn get_template(&self, id: &PolicyID) -> Option<Arc<Template>>
pub fn get_template(&self, id: &PolicyID) -> Option<Arc<Template>>
Lookup a template by policy id
sourcepub fn try_from_iter<T: IntoIterator<Item = Policy>>(
iter: T,
) -> Result<Self, PolicySetError>
pub fn try_from_iter<T: IntoIterator<Item = Policy>>( iter: T, ) -> Result<Self, PolicySetError>
Attempt to collect an iterator over policies into a PolicySet
Trait Implementations§
source§impl<'de> Deserialize<'de> for PolicySet
impl<'de> Deserialize<'de> for PolicySet
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for PolicySet
impl StructuralPartialEq 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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
Converts
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>
Converts
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