cedar_policy_core::ast

Struct TemplateBody

Source
pub struct TemplateBody { /* private fields */ }
Expand description

Policy datatype. This is used for both templates (in which case it contains slots) and static policies (in which case it contains zero slots).

Implementations§

Source§

impl TemplateBody

Source

pub fn id(&self) -> &PolicyID

Get the Id of this policy.

Source

pub fn loc(&self) -> Option<&Loc>

Get the location of this policy

Source

pub fn new_id(&self, id: PolicyID) -> Self

Clone this policy with a new Id.

Source

pub fn effect(&self) -> Effect

Get the Effect of this policy.

Source

pub fn annotation(&self, key: &AnyId) -> Option<&Annotation>

Get data from an annotation.

Source

pub fn annotations_arc(&self) -> &Arc<Annotations>

Get shared ref to annotations

Source

pub fn annotations(&self) -> impl Iterator<Item = (&AnyId, &Annotation)>

Get all annotation data.

Source

pub fn principal_constraint(&self) -> &PrincipalConstraint

Get the principal scope constraint of this policy.

Source

pub fn principal_constraint_expr(&self) -> Expr

Get the principal scope constraint as an expression. This will be a boolean-valued expression: either true (if the policy just has principal,), or an equality or hierarchy constraint

Source

pub fn action_constraint(&self) -> &ActionConstraint

Get the action scope constraint of this policy.

Source

pub fn action_constraint_expr(&self) -> Expr

Get the action scope constraint of this policy as an expression. This will be a boolean-valued expression: either true (if the policy just has action,), or an equality or hierarchy constraint

Source

pub fn resource_constraint(&self) -> &ResourceConstraint

Get the resource scope constraint of this policy.

Source

pub fn resource_constraint_expr(&self) -> Expr

Get the resource scope constraint of this policy as an expression. This will be a boolean-valued expression: either true (if the policy just has resource,), or an equality or hierarchy constraint

Source

pub fn non_scope_constraints(&self) -> &Expr

Get the non-scope constraints of this policy.

This will be a conjunction of the policy’s when conditions and the negation of each of the policy’s unless conditions.

Source

pub fn non_scope_constraints_arc(&self) -> &Arc<Expr>

Get the Arc owning the non scope constraints

Source

pub fn condition(&self) -> Expr

Get the condition expression of this policy.

This will be a conjunction of the policy’s scope constraints (on principal, resource, and action); the policy’s “when” conditions; and the negation of each of the policy’s “unless” conditions.

Source

pub fn new_shared( id: PolicyID, loc: Option<Loc>, annotations: Arc<Annotations>, effect: Effect, principal_constraint: PrincipalConstraint, action_constraint: ActionConstraint, resource_constraint: ResourceConstraint, non_scope_constraints: Arc<Expr>, ) -> Self

Construct a Policy from components that are already std::sync::Arc allocated

Source

pub fn new( id: PolicyID, loc: Option<Loc>, annotations: Annotations, effect: Effect, principal_constraint: PrincipalConstraint, action_constraint: ActionConstraint, resource_constraint: ResourceConstraint, non_scope_constraints: Expr, ) -> Self

Construct a Policy from its components

Trait Implementations§

Source§

impl Clone for TemplateBody

Source§

fn clone(&self) -> TemplateBody

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 TemplateBody

Source§

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

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

impl<'de> Deserialize<'de> for TemplateBody

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 TemplateBody

Source§

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

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

impl From<StaticPolicy> for TemplateBody

Source§

fn from(p: StaticPolicy) -> Self

Converts to this type from the input type.
Source§

impl From<Template> for TemplateBody

Source§

fn from(val: Template) -> Self

Converts to this type from the input type.
Source§

impl From<TemplateBody> for Template

Source§

fn from(body: TemplateBody) -> Self

Converts to this type from the input type.
Source§

impl Hash for TemplateBody

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TemplateBody

Source§

fn eq(&self, other: &TemplateBody) -> 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 TemplateBody

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 TemplateBody

Source§

impl StructuralPartialEq for TemplateBody

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>,