Enum cedar_policy_core::ast::ExprKind

source ·
pub enum ExprKind<T = ()> {
Show 15 variants Lit(Literal), Var(Var), Slot(SlotId), Unknown { name: SmolStr, type_annotation: Option<Type>, }, If { test_expr: Arc<Expr<T>>, then_expr: Arc<Expr<T>>, else_expr: Arc<Expr<T>>, }, And { left: Arc<Expr<T>>, right: Arc<Expr<T>>, }, Or { left: Arc<Expr<T>>, right: Arc<Expr<T>>, }, UnaryApp { op: UnaryOp, arg: Arc<Expr<T>>, }, BinaryApp { op: BinaryOp, arg1: Arc<Expr<T>>, arg2: Arc<Expr<T>>, }, ExtensionFunctionApp { fn_name: Name, args: Arc<Vec<Expr<T>>>, }, GetAttr { expr: Arc<Expr<T>>, attr: SmolStr, }, HasAttr { expr: Arc<Expr<T>>, attr: SmolStr, }, Like { expr: Arc<Expr<T>>, pattern: Pattern, }, Set(Arc<Vec<Expr<T>>>), Record { pairs: Arc<Vec<(SmolStr, Expr<T>)>>, },
}
Expand description

The possible expression variants. This enum should be matched on by code recursively traversing the AST.

Variants§

§

Lit(Literal)

Literal value

§

Var(Var)

Variable

§

Slot(SlotId)

Template Slots

§

Unknown

Symbolic Unknown for partial-eval

Fields

§name: SmolStr

The name of the unknown

§type_annotation: Option<Type>

The type of the values that can be substituted in for the unknown If None, we have no type annotation, and thus a value of any type can be substituted.

§

If

Ternary expression

Fields

§test_expr: Arc<Expr<T>>

Condition for the ternary expression. Must evaluate to Bool type

§then_expr: Arc<Expr<T>>

Value if true

§else_expr: Arc<Expr<T>>

Value if false

§

And

Boolean AND

Fields

§left: Arc<Expr<T>>

Left operand, which will be eagerly evaluated

§right: Arc<Expr<T>>

Right operand, which may not be evaluated due to short-circuiting

§

Or

Boolean OR

Fields

§left: Arc<Expr<T>>

Left operand, which will be eagerly evaluated

§right: Arc<Expr<T>>

Right operand, which may not be evaluated due to short-circuiting

§

UnaryApp

Application of a built-in unary operator (single parameter)

Fields

§op: UnaryOp

Unary operator to apply

§arg: Arc<Expr<T>>

Argument to apply operator to

§

BinaryApp

Application of a built-in binary operator (two parameters)

Fields

§op: BinaryOp

Binary operator to apply

§arg1: Arc<Expr<T>>

First arg

§arg2: Arc<Expr<T>>

Second arg

§

ExtensionFunctionApp

Application of an extension function to n arguments INVARIANT (MethodStyleArgs): if op.style is MethodStyle then args cannot be empty. The first element of args refers to the subject of the method call Ideally, we find some way to make this non-representable.

Fields

§fn_name: Name

Extension function to apply

§args: Arc<Vec<Expr<T>>>

Args to apply the function to

§

GetAttr

Get an attribute of an entity, or a field of a record

Fields

§expr: Arc<Expr<T>>

Expression to get an attribute/field of. Must evaluate to either Entity or Record type

§attr: SmolStr

Attribute or field to get

§

HasAttr

Does the given expr have the given attr?

Fields

§expr: Arc<Expr<T>>

Expression to test. Must evaluate to either Entity or Record type

§attr: SmolStr

Attribute or field to check for

§

Like

Regex-like string matching similar to IAM’s StringLike operator.

Fields

§expr: Arc<Expr<T>>

Expression to test. Must evaluate to String type

§pattern: Pattern

Pattern to match on; can include the wildcard *, which matches any string. To match a literal * in the test expression, users can use \*. Be careful the backslash in \* must not be another escape sequence. For instance, \\* matches a backslash plus an arbitrary string.

§

Set(Arc<Vec<Expr<T>>>)

Set (whose elements may be arbitrary expressions)

§

Record

Anonymous record (whose elements may be arbitrary expressions) This is a Vec for the same reason as above.

Fields

§pairs: Arc<Vec<(SmolStr, Expr<T>)>>

key/value pairs

Trait Implementations§

source§

impl<T: Clone> Clone for ExprKind<T>

source§

fn clone(&self) -> ExprKind<T>

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<T: Debug> Debug for ExprKind<T>

source§

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

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

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

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<T: Hash> Hash for ExprKind<T>

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<T: PartialEq> PartialEq for ExprKind<T>

source§

fn eq(&self, other: &ExprKind<T>) -> 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<T> Serialize for ExprKind<T>
where T: Serialize,

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<T: Eq> Eq for ExprKind<T>

source§

impl<T> StructuralPartialEq for ExprKind<T>

Auto Trait Implementations§

§

impl<T> Freeze for ExprKind<T>

§

impl<T> RefUnwindSafe for ExprKind<T>
where T: RefUnwindSafe,

§

impl<T> Send for ExprKind<T>
where T: Sync + Send,

§

impl<T> Sync for ExprKind<T>
where T: Sync + Send,

§

impl<T> Unpin for ExprKind<T>

§

impl<T> UnwindSafe for ExprKind<T>
where T: RefUnwindSafe,

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