rets_expression

Enum Expression

Source
pub enum Expression {
    Field(FieldNode),
    LastField(LastFieldNode),
    And(AndNode),
    Or(OrNode),
    Not(NotNode),
    Op(OpNode),
    Literal(LiteralNode),
    Function(FunctionNode),
    Iif(IifNode),
    List(ListNode),
}
Expand description

An expression that can be inspected or evaluated

Variants§

§

Field(FieldNode)

A node representing a reference to a field

E.g. MlsStatus

§

LastField(LastFieldNode)

A node representing a reference to a field from the previous value

E.g. LAST MlsStatus

§

And(AndNode)

A node representing the logical conjunction of two or more expressions

E.g. A .AND. B

§

Or(OrNode)

A node representing the logical disjunction of two or more expressions

E.g. A .OR. B

§

Not(NotNode)

A node representing the logical negation of an expression

E.g. .NOT. A

§

Op(OpNode)

A node representing a binary operation

E.g. A + B

§

Literal(LiteralNode)

A node representing a literal value

E.g. .TRUE.

§

Function(FunctionNode)

A node representing a function call

E.g. SUBSTR('A', 1, 2)

§

Iif(IifNode)

A node representing the special IIF conditional syntax

E.g. IIF(A, B, C)

§

List(ListNode)

A node representing a list of items

E.g. (1, 2, 3)

Implementations§

Source§

impl Expression

Source

pub fn serialize(&self) -> Result<String, Error>

Serialize the expression to a string

Source

pub fn format<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write,

Serialize the expression to a writer

Source§

impl Expression

Source

pub fn accept(&mut self, visitor: &mut impl Visitor)

Visit this node with the provided visitor

Source§

impl Expression

Source

pub fn as_field(&self) -> Option<&FieldNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_field_mut(&mut self) -> Option<&mut FieldNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_last_field(&self) -> Option<&LastFieldNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_last_field_mut(&mut self) -> Option<&mut LastFieldNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_and(&self) -> Option<&AndNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_and_mut(&mut self) -> Option<&mut AndNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_or(&self) -> Option<&OrNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_or_mut(&mut self) -> Option<&mut OrNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_not(&self) -> Option<&NotNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_not_mut(&mut self) -> Option<&mut NotNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_op(&self) -> Option<&OpNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_op_mut(&mut self) -> Option<&mut OpNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_literal(&self) -> Option<&LiteralNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_literal_mut(&mut self) -> Option<&mut LiteralNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_function(&self) -> Option<&FunctionNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_function_mut(&mut self) -> Option<&mut FunctionNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_iif(&self) -> Option<&IifNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_iif_mut(&mut self) -> Option<&mut IifNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source

pub fn as_list(&self) -> Option<&ListNode>

If the Expression is a X, returns a reference to the associated Y. Returns None otherwise.

Source

pub fn as_list_mut(&mut self) -> Option<&mut ListNode>

If the Expression is a X, returns a mutable reference to the associated Y. Returns None otherwise.

Source§

impl Expression

Source

pub fn apply<'expr, 'val, T>( &'expr self, context: EvaluateContext<'_, 'val, T>, ) -> Result<Cow<'val, Value>, Error>
where 'expr: 'val,

Run the expression to completion and return the result

Source

pub fn apply_with_locals<'expr, 'val, T>( &'expr self, context: EvaluateContext<'_, 'val, T>, locals: &BTreeMap<&'expr str, Cow<'val, Value>>, ) -> Result<Cow<'val, Value>, Error>
where 'expr: 'val,

Run the expression to completion and return the result

Locals can be used to augment or override the provided JSON values.

Trait Implementations§

Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

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 Expression

Source§

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

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

impl From<AndNode> for Expression

Source§

fn from(node: AndNode) -> Expression

Converts to this type from the input type.
Source§

impl From<FieldNode> for Expression

Source§

fn from(node: FieldNode) -> Expression

Converts to this type from the input type.
Source§

impl From<FunctionNode> for Expression

Source§

fn from(node: FunctionNode) -> Expression

Converts to this type from the input type.
Source§

impl From<IifNode> for Expression

Source§

fn from(node: IifNode) -> Expression

Converts to this type from the input type.
Source§

impl From<LastFieldNode> for Expression

Source§

fn from(node: LastFieldNode) -> Expression

Converts to this type from the input type.
Source§

impl From<ListNode> for Expression

Source§

fn from(node: ListNode) -> Expression

Converts to this type from the input type.
Source§

impl From<LiteralNode> for Expression

Source§

fn from(node: LiteralNode) -> Expression

Converts to this type from the input type.
Source§

impl From<NotNode> for Expression

Source§

fn from(node: NotNode) -> Expression

Converts to this type from the input type.
Source§

impl From<OpNode> for Expression

Source§

fn from(node: OpNode) -> Expression

Converts to this type from the input type.
Source§

impl From<OrNode> for Expression

Source§

fn from(node: OrNode) -> Expression

Converts to this type from the input type.
Source§

impl FromStr for Expression

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Expression

Source§

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

Source§

impl StructuralPartialEq for Expression

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