Struct Builder

Source
pub struct Builder;
Expand description

Construct an Expr.

Trait Implementations§

Source§

impl Clone for Builder

Source§

fn clone(&self) -> Builder

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 Builder

Source§

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

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

impl ExprBuilder for Builder

Source§

fn val(self, lit: impl Into<Literal>) -> Expr

literal

Source§

fn var(self, var: Var) -> Expr

principal, action, resource, context

Source§

fn slot(self, slot: SlotId) -> Expr

Template slots

Source§

fn unknown(self, u: Unknown) -> Expr

An extension call with one arg, which is the name of the unknown

Source§

fn not(self, e: Expr) -> Expr

!

Source§

fn neg(self, e: Expr) -> Expr

-

Source§

fn is_eq(self, left: Expr, right: Expr) -> Expr

==

Source§

fn noteq(self, left: Expr, right: Expr) -> Expr

!=

Source§

fn is_in(self, left: Expr, right: Expr) -> Expr

in

Source§

fn less(self, left: Expr, right: Expr) -> Expr

<

Source§

fn lesseq(self, left: Expr, right: Expr) -> Expr

<=

Source§

fn greater(self, left: Expr, right: Expr) -> Expr

>

Source§

fn greatereq(self, left: Expr, right: Expr) -> Expr

>=

Source§

fn and(self, left: Expr, right: Expr) -> Expr

&&

Source§

fn or(self, left: Expr, right: Expr) -> Expr

||

Source§

fn add(self, left: Expr, right: Expr) -> Expr

+

Source§

fn sub(self, left: Expr, right: Expr) -> Expr

-

Source§

fn mul(self, left: Expr, right: Expr) -> Expr

*

Source§

fn contains(self, left: Expr, right: Expr) -> Expr

left.contains(right)

Source§

fn contains_all(self, left: Expr, right: Expr) -> Expr

left.containsAll(right)

Source§

fn contains_any(self, left: Expr, right: Expr) -> Expr

left.containsAny(right)

Source§

fn is_empty(self, expr: Expr) -> Expr

arg.isEmpty()

Source§

fn get_tag(self, expr: Expr, tag: Expr) -> Expr

left.getTag(right)

Source§

fn has_tag(self, expr: Expr, tag: Expr) -> Expr

left.hasTag(right)

Source§

fn get_attr(self, expr: Expr, attr: SmolStr) -> Expr

left.attr

Source§

fn has_attr(self, expr: Expr, attr: SmolStr) -> Expr

left has attr

Source§

fn like(self, expr: Expr, pattern: Pattern) -> Expr

left like pattern

Source§

fn is_entity_type(self, left: Expr, entity_type: EntityType) -> Expr

left is entity_type

Source§

fn is_in_entity_type( self, left: Expr, entity_type: EntityType, entity: Expr, ) -> Expr

left is entity_type in entity

Source§

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

if cond_expr then then_expr else else_expr

Source§

fn set(self, elements: impl IntoIterator<Item = Expr>) -> Expr

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

Source§

fn record( self, map: impl IntoIterator<Item = (SmolStr, Expr)>, ) -> Result<Expr, ExpressionConstructionError>

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

Source§

fn call_extension_fn( self, fn_name: Name, args: impl IntoIterator<Item = Expr>, ) -> Expr

extension function call, including method calls

Source§

type Expr = Expr

The type of expression constructed by this instance of ExprBuilder.
Source§

type Data = ()

Type for extra information stored on nodes of the expression AST. This can be () if no data is stored.
Source§

fn with_data(_data: Self::Data) -> Self

Build an expression storing this information
Source§

fn with_maybe_source_loc(self, _: Option<&Loc>) -> Self

Build an expression located at l, if l is Some. An implementation may ignore this if it cannot store source information.
Source§

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

Extract the location for this builder, if set. Used internally to provide utilities that construct multiple nodes which should all be reported as having the same source location.
Source§

fn data(&self) -> &Self::Data

Extract the data that will be stored on the constructed expression. Used internally to provide utilities that construct multiple nodes which will all have the same data.
Source§

fn new() -> Self
where Self: Sized,

Construct a new expression builder for an expression that will not carry any data.
Source§

fn with_source_loc(self, l: &Loc) -> Self
where Self: Sized,

Build an expression located at l. An implementation may ignore this if it cannot store source information.
Source§

fn unary_app(self, op: impl Into<UnaryOp>, arg: Self::Expr) -> Self::Expr
where Self: Sized,

Create an application Expr which applies the given built-in unary operator to the given arg
Source§

fn binary_app( self, op: impl Into<BinaryOp>, arg1: Self::Expr, arg2: Self::Expr, ) -> Self::Expr
where Self: Sized,

Create an application Expr which applies the given built-in binary operator to arg1 and arg2
Source§

fn and_nary( self, first: Self::Expr, others: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr
where Self: Sized,

Create an and expression that may have more than two subexpressions (A && B && C) or may have only one subexpression, in which case no && is performed at all. Arguments must evaluate to Bool type. Read more
Source§

fn or_nary( self, first: Self::Expr, others: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr
where Self: Sized,

Create an or expression that may have more than two subexpressions (A || B || C) or may have only one subexpression, in which case no || is performed at all. Arguments must evaluate to Bool type. Read more
Source§

fn add_nary( self, first: Self::Expr, other: impl IntoIterator<Item = (AddOp, Self::Expr)>, ) -> Self::Expr
where Self: Sized,

Create expression containing addition and subtraction that may have more than two subexpressions (A + B - C) or may have only one subexpression, in which case no operations are performed at all.
Source§

fn mul_nary( self, first: Self::Expr, other: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr
where Self: Sized,

Create expression containing multiplication that may have more than two subexpressions (A * B * C) or may have only one subexpression, in which case no operations are performed at all.

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 u8)

🔬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.