Struct cedar_policy_core::ast::PolicySet

source ·
pub struct PolicySet { /* private fields */ }
Expand description

Represents a set of Policys

Implementations§

source§

impl PolicySet

source

pub fn new() -> Self

Create a fresh empty PolicySet

source

pub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>

Add a Policy to the PolicySet.

source

pub fn add_static(&mut self, policy: StaticPolicy) -> Result<(), PolicySetError>

Add a StaticPolicy to the PolicySet.

source

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.

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

  1. The the passed SlotEnv either does not match the slots in the templates
  2. The passed link Id conflicts with an Id already in the set
source

pub fn policies(&self) -> impl Iterator<Item = &Policy>

Iterate over all policies

source

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())

source

pub fn templates(&self) -> impl Iterator<Item = &Template>

Iterate over templates with slots

source

pub fn static_policies(&self) -> impl Iterator<Item = &Policy>

Iterate over all of the static policies.

source

pub fn is_empty(&self) -> bool

Returns true iff the PolicySet is empty

source

pub fn get_template(&self, id: &PolicyID) -> Option<Arc<Template>>

Lookup a template by policy id

source

pub fn get(&self, id: &PolicyID) -> Option<&Policy>

Lookup an policy by policy id

source

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 Clone for PolicySet

source§

fn clone(&self) -> PolicySet

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PolicySet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PolicySet

source§

fn default() -> PolicySet

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for PolicySet

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for PolicySet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for PolicySet

source§

fn eq(&self, other: &PolicySet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for PolicySet

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for PolicySet

source§

impl StructuralPartialEq for PolicySet

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,