Skip to main content

Expr

Struct Expr 

Source
pub struct Expr<T: FromValue = OwnedDataValue> { /* private fields */ }
Expand description

Compiled JSONLogic resolving to a T, made by ExprEngine::compile.

An expression that reads nothing folds at compile into a constant, and every evaluation lends that constant from the expression, never cloning it.

Implementations§

Source§

impl<T: FromValue> Expr<T>

Source

pub fn constant(&self) -> Option<&T>

The folded constant, if the expression reads nothing.

Source

pub fn raw(&self) -> &Value

The authored JSON.

Trait Implementations§

Source§

impl<T: FromValue> ConfigField for Expr<T>

Source§

const NULL_IS_VALUE: bool = true

null is a constant expression.

Source§

fn compile(raw: &Value, cx: &mut CompileCx<'_>) -> Option<Self>

Compiles raw; None after recording at least one issue.
Source§

fn visit(&self, v: &mut Visit<'_>)

Reports the field’s expressions.
Source§

fn resolve(&self, r: &mut dyn Resolver) -> Result<Option<OwnedDataValue>>

The field’s value for this call, resolved through r, or None when it has none (an Option the input left unset, with no default). The value sits where Self::visit reports the field’s expressions: a list’s elements at their indices, a map’s values at their keys, and an element left unset is null, keeping its place. Read more
Source§

fn kind() -> FieldKind

What the field is.
Source§

const IS_OUTPUT: bool = false

Whether the field is an output: a destination its call writes to. false unless the type is Output or an Option of one. The derive reads a field typed Output or marked #[output] as an output and asserts that this is true, so a type that merely shares the name is refused at compile time.
Source§

fn absent() -> Option<Self>

The value when the key is absent and no default is declared. None makes the field required.
Source§

impl<T: FromValue> Debug for Expr<T>

Source§

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

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

impl<T: FromValue> ResolveExpr for Expr<T>

Source§

fn raw(&self) -> &Value

The authored JSON.

Auto Trait Implementations§

§

impl<T = OwnedDataValue> !Freeze for Expr<T>

§

impl<T> RefUnwindSafe for Expr<T>

§

impl<T> Send for Expr<T>
where Option<T>: Send,

§

impl<T> Sync for Expr<T>
where Option<T>: Sync,

§

impl<T> Unpin for Expr<T>
where Option<T>: Unpin,

§

impl<T> UnsafeUnpin for Expr<T>
where Option<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Expr<T>
where Option<T>: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.