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
impl Expr
sourcepub fn lit(lit: CedarValueJson) -> Self
pub fn lit(lit: CedarValueJson) -> Self
literal
sourcepub fn contains_all(left: Arc<Expr>, right: Expr) -> Self
pub fn contains_all(left: Arc<Expr>, right: Expr) -> Self
left.containsAll(right)
sourcepub fn contains_any(left: Arc<Expr>, right: Expr) -> Self
pub fn contains_any(left: Arc<Expr>, right: Expr) -> Self
left.containsAny(right)
sourcepub fn is_entity_type(left: Expr, entity_type: SmolStr) -> Self
pub fn is_entity_type(left: Expr, entity_type: SmolStr) -> Self
left is entity_type
sourcepub fn is_entity_type_in(left: Expr, entity_type: SmolStr, entity: Expr) -> Self
pub fn is_entity_type_in(left: Expr, entity_type: SmolStr, entity: Expr) -> Self
left is entity_type in entity
sourcepub fn ite(cond_expr: Expr, then_expr: Expr, else_expr: Expr) -> Self
pub fn ite(cond_expr: Expr, then_expr: Expr, else_expr: Expr) -> Self
if cond_expr then then_expr else else_expr
sourcepub fn record(map: HashMap<SmolStr, Expr>) -> Self
pub fn record(map: HashMap<SmolStr, Expr>) -> Self
e.g. {foo: 1+2, bar: !(context has department)}
sourcepub fn ext_call(fn_name: SmolStr, args: Vec<Expr>) -> Self
pub fn ext_call(fn_name: SmolStr, args: Vec<Expr>) -> Self
extension function call, including method calls
sourcepub fn into_string_literal(self) -> Result<SmolStr, Self>
pub fn into_string_literal(self) -> Result<SmolStr, Self>
Consume the Expr
, producing a string literal if it was a string literal, otherwise returns the literal in the Err
variant.
source§impl Expr
impl Expr
sourcepub fn try_into_ast(self, id: PolicyID) -> Result<Expr, FromJsonError>
pub fn try_into_ast(self, id: PolicyID) -> Result<Expr, FromJsonError>
Attempt to convert this est::Expr
into an ast::Expr
id
: the ID of the policy this Expr
belongs to, used only for reporting errors
Trait Implementations§
source§impl<'de> Deserialize<'de> for Expr
impl<'de> Deserialize<'de> for Expr
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Expr
impl PartialEq for Expr
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> 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<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