Enum interface::Expression[][src]

pub enum Expression {
    Tag {
        tag: String,
    },
    KeyValue {
        key: String,
        value: String,
    },
    HasKey {
        key: String,
    },
    Parent {
        parent: String,
    },
    And {
        and: (Box<Expression, Global>, Box<Expression, Global>),
    },
    Or {
        or: (Box<Expression, Global>, Box<Expression, Global>),
    },
    Not {
        not: Box<Expression, Global>,
    },
    Empty,
}

A parsed (or manually constructed) query expression.

An expression can be arbitrarily nested.

Variants

Tag

Tag expression.

Evaluates to resolver items where the tag is present.

Fields of Tag

tag: String
KeyValue

Key/Value expression.

Evaluates to resolver items where the given key/value pair is present.

Fields of KeyValue

key: Stringvalue: String
HasKey

HasKey expression.

Evaluates to resolver items where the given key is present (in any key/value pair).

Fields of HasKey

key: String
Parent

Parent expression.

Evaluates to resolver items having the provided value as a parent.

Fields of Parent

parent: String
And

And expression.

Evaluates to the intersection of its two sub-expressions.

Fields of And

and: (Box<Expression, Global>, Box<Expression, Global>)
Or

Or expression. Evaluates to the union of its two sub-expressions.

Fields of Or

or: (Box<Expression, Global>, Box<Expression, Global>)
Not

Not expression. Evaluates to the negation of its sub-expression.

Fields of Not

not: Box<Expression, Global>
Empty

Empty expression. Evaluates to all items resolvable by the resolver.

Implementations

impl Expression[src]

pub fn parse<S>(str_expr: S) -> Result<Expression, Error> where
    S: AsRef<str>, 
[src]

Parse an expression from a string.

Returns an error if the provided string could not be parsed.

Examples

use rapidquery::Expression;

let expression = "a && b";
match Expression::parse(expression) {
    Ok(expr) => println!("Got expression: {:?}", expr),
    Err(e) => panic!("failed to parse")
}

pub fn evaluate<R, V, E>(&self, resolver: &R) -> Result<V, E> where
    V: BitAndAssign<V> + BitOrAssign<V> + Not<Output = V> + Span + Display,
    R: Resolver<V, Error = E>, 
[src]

Evaluate an expression using a resolver.

The resolver is tasked with resolving the sets corresponding to the various sub-expressions kinds (tags, key/value pairs, etc.). From there, the evaluator will recursively compute the query, calling the resolver when appropriate.

Examples

use rapidquery::{Expression, Resolver};

let resolver: Box<dyn Resolver<bool, Error = std::io::Error>> = {
    unimplemented!()
};

let expr = Expression::Empty;;

let evaluation: bool = expr.evaluate(&resolver)?;

Trait Implementations

impl Clone for Expression[src]

impl Debug for Expression[src]

impl Default for Expression[src]

impl<'de> Deserialize<'de> for Expression[src]

impl Eq for Expression[src]

impl From<ParsedExpr> for Expression[src]

impl From<Term> for Expression[src]

impl Hash for Expression[src]

impl PartialEq<Expression> for Expression[src]

impl Serialize for Expression[src]

impl StructuralEq for Expression[src]

impl StructuralPartialEq for Expression[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,