Struct cedar_policy::Policy
source · pub struct Policy { /* private fields */ }
Expand description
Structure for a Policy
. Includes both static policies and template-linked policies.
Implementations§
source§impl Policy
impl Policy
sourcepub fn template_id(&self) -> Option<&PolicyId>
pub fn template_id(&self) -> Option<&PolicyId>
Get the PolicyId
of the Template
this is linked to of.
If this is an static policy, this will return None
.
sourcepub fn annotation(&self, key: impl AsRef<str>) -> Option<&str>
pub fn annotation(&self, key: impl AsRef<str>) -> Option<&str>
Get an annotation value of this template-linked or static policy
sourcepub fn annotations(&self) -> impl Iterator<Item = (&str, &str)>
pub fn annotations(&self) -> impl Iterator<Item = (&str, &str)>
Iterate through annotation data of this template-linked or static policy
sourcepub fn principal_constraint(&self) -> PrincipalConstraint
pub fn principal_constraint(&self) -> PrincipalConstraint
Get the head constraint on this policy’s principal
sourcepub fn action_constraint(&self) -> ActionConstraint
pub fn action_constraint(&self) -> ActionConstraint
Get the head constraint on this policy’s action
sourcepub fn resource_constraint(&self) -> ResourceConstraint
pub fn resource_constraint(&self) -> ResourceConstraint
Get the head constraint on this policy’s resource
sourcepub fn parse(
id: Option<String>,
policy_src: impl AsRef<str>
) -> Result<Self, ParseErrors>
pub fn parse( id: Option<String>, policy_src: impl AsRef<str> ) -> Result<Self, ParseErrors>
Parse a single policy.
If id
is Some, the policy will be given that Policy Id.
If id
is None, then “policy0” will be used.
The behavior around None may change in the future.
Trait Implementations§
source§impl FromStr for Policy
impl FromStr for Policy
source§fn from_str(policy: &str) -> Result<Self, Self::Err>
fn from_str(policy: &str) -> Result<Self, Self::Err>
Create a policy
Important note: Policies have ids, but this interface does not
allow them to be set. It will use the default “policy0”, which
may cause id conflicts if not handled. Use Policy::parse
to set
the id when parsing, or Policy::new_id
to clone a policy with
a new id.
§type Err = ParseErrors
type Err = ParseErrors
source§impl PartialEq<Policy> for Policy
impl PartialEq<Policy> for Policy
impl Eq for Policy
Auto Trait Implementations§
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnwindSafe for Policy
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.