Struct cedar_policy::Template
source · pub struct Template { /* private fields */ }
Expand description
Policy template datatype
Implementations§
source§impl Template
impl Template
sourcepub fn parse(
id: Option<String>,
src: impl AsRef<str>
) -> Result<Self, ParseErrors>
pub fn parse( id: Option<String>, src: impl AsRef<str> ) -> Result<Self, ParseErrors>
Attempt to parse a Template
from source.
If id
is Some, then the resulting template will have that id
.
If the id
is None, the parser will use the default “policy0”.
The behavior around None may change in the future.
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
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
as key-value pairs
sourcepub fn slots(&self) -> impl Iterator<Item = &SlotId>
pub fn slots(&self) -> impl Iterator<Item = &SlotId>
Iterate over the open slots in this Template
sourcepub fn principal_constraint(&self) -> TemplatePrincipalConstraint
pub fn principal_constraint(&self) -> TemplatePrincipalConstraint
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) -> TemplateResourceConstraint
pub fn resource_constraint(&self) -> TemplateResourceConstraint
Get the head constraint on this policy’s resource
sourcepub fn from_json(
id: Option<PolicyId>,
json: Value
) -> Result<Self, FromJsonError>
pub fn from_json( id: Option<PolicyId>, json: Value ) -> Result<Self, FromJsonError>
Create a Template
from its JSON representation.
If id
is Some, the policy will be given that Policy Id.
If id
is None, then “JSON policy” will be used.
The behavior around None may change in the future.
sourcepub fn to_json(&self) -> Result<Value, impl Diagnostic>
pub fn to_json(&self) -> Result<Value, impl Diagnostic>
Get the JSON representation of this Template
.
Trait Implementations§
source§impl PartialEq for Template
impl PartialEq for Template
impl Eq for Template
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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<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