Enum cedar_policy_core::est::Expr

source ·
pub enum Expr {
    ExprNoExt(ExprNoExt),
    ExtFuncCall(ExtFuncCall),
}
Expand description

Serde JSON structure for a Cedar expression in the EST format

Variants§

§

ExprNoExt(ExprNoExt)

Any Cedar expression other than an extension function call. We try to match this first, see docs on #[serde(untagged)].

§

ExtFuncCall(ExtFuncCall)

If that didn’t match (because the key is not one of the keys defined in ExprNoExt), we assume we have an extension function call, where the key is the name of an extension function or method.

Implementations§

source§

impl Expr

source

pub fn lit(lit: JSONValue) -> Self

literal

source

pub fn var(var: Var) -> Self

principal, action, resource, context

source

pub fn slot(slot: SlotId) -> Self

Template slots

source

pub fn unknown(name: impl Into<SmolStr>) -> Self

Partial-evaluation unknowns

source

pub fn not(e: Expr) -> Self

!

source

pub fn neg(e: Expr) -> Self

-

source

pub fn eq(left: Expr, right: Expr) -> Self

==

source

pub fn noteq(left: Expr, right: Expr) -> Self

!=

source

pub fn _in(left: Expr, right: Expr) -> Self

in

source

pub fn less(left: Expr, right: Expr) -> Self

<

source

pub fn lesseq(left: Expr, right: Expr) -> Self

<=

source

pub fn greater(left: Expr, right: Expr) -> Self

>

source

pub fn greatereq(left: Expr, right: Expr) -> Self

>=

source

pub fn and(left: Expr, right: Expr) -> Self

&&

source

pub fn or(left: Expr, right: Expr) -> Self

||

source

pub fn add(left: Expr, right: Expr) -> Self

+

source

pub fn sub(left: Expr, right: Expr) -> Self

-

source

pub fn mul(left: Expr, right: Expr) -> Self

*

source

pub fn contains(left: Arc<Expr>, right: Expr) -> Self

left.contains(right)

source

pub fn contains_all(left: Arc<Expr>, right: Expr) -> Self

left.containsAll(right)

source

pub fn contains_any(left: Arc<Expr>, right: Expr) -> Self

left.containsAny(right)

source

pub fn get_attr(left: Expr, attr: SmolStr) -> Self

left.attr

source

pub fn has_attr(left: Expr, attr: SmolStr) -> Self

left has attr

source

pub fn like(left: Expr, pattern: SmolStr) -> Self

left like pattern

source

pub fn ite(cond_expr: Expr, then_expr: Expr, else_expr: Expr) -> Self

if cond_expr then then_expr else else_expr

source

pub fn set(elements: Vec<Expr>) -> Self

e.g. [1+2, !(context has department)]

source

pub fn record(map: HashMap<SmolStr, Expr>) -> Self

e.g. {foo: 1+2, bar: !(context has department)}

source

pub fn ext_call(fn_name: SmolStr, args: Vec<Expr>) -> Self

extension function call, including method calls

source

pub fn into_string_literal(self) -> Option<SmolStr>

Consume the Expr, producing a string literal if it was a string literal, otherwise None

Trait Implementations§

source§

impl Clone for Expr

source§

fn clone(&self) -> Expr

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 Expr

source§

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

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

impl<'de> Deserialize<'de> for Expr

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 From<Expr> for Expr

source§

fn from(expr: Expr) -> Expr

Converts to this type from the input type.
source§

impl From<Literal> for Expr

source§

fn from(lit: Literal) -> Expr

Converts to this type from the input type.
source§

impl From<SlotId> for Expr

source§

fn from(slot: SlotId) -> Expr

Converts to this type from the input type.
source§

impl From<Var> for Expr

source§

fn from(var: Var) -> Expr

Converts to this type from the input type.
source§

impl PartialEq for Expr

source§

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

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 TryFrom<Add> for Expr

source§

type Error = ParseErrors

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

fn try_from(a: Add) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<And> for Expr

source§

type Error = ParseErrors

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

fn try_from(a: And) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Expr> for Expr

source§

type Error = EstToAstError

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

fn try_from(expr: Expr) -> Result<Expr, EstToAstError>

Performs the conversion.
source§

impl TryFrom<Expr> for Expr

source§

type Error = ParseErrors

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

fn try_from(e: Expr) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Literal> for Expr

source§

type Error = ParseErrors

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

fn try_from(lit: Literal) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Member> for Expr

source§

type Error = ParseErrors

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

fn try_from(m: Member) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Mult> for Expr

source§

type Error = ParseErrors

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

fn try_from(m: Mult) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Name> for Expr

source§

type Error = ParseErrors

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

fn try_from(name: Name) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Or> for Expr

source§

type Error = ParseErrors

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

fn try_from(o: Or) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Relation> for Expr

source§

type Error = ParseErrors

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

fn try_from(r: Relation) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl TryFrom<Unary> for Expr

source§

type Error = ParseErrors

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

fn try_from(u: Unary) -> Result<Expr, ParseErrors>

Performs the conversion.
source§

impl StructuralPartialEq for Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnwindSafe for Expr

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