Filter

Trait Filter 

Source
pub trait Filter<V: Debug + Send + Sync + Clone + 'static>: DynClone {
    // Required methods
    fn exists(
        &self,
        field: Field,
    ) -> Result<Box<dyn Matcher<V>>, PathParseError>;
    fn equals(
        &self,
        field: Field,
        to_match: &str,
    ) -> Result<Box<dyn Matcher<V>>, PathParseError>;
    fn prefix(
        &self,
        field: Field,
        prefix: &str,
    ) -> Result<Box<dyn Matcher<V>>, PathParseError>;
    fn wildcard(
        &self,
        field: Field,
        wildcard: &str,
    ) -> Result<Box<dyn Matcher<V>>, PathParseError>;
    fn compare(
        &self,
        field: Field,
        comparator: Comparison,
        comparison_value: ComparisonValue,
    ) -> Result<Box<dyn Matcher<V>>, PathParseError>;

    // Provided method
    fn range(
        &self,
        field: Field,
        lower: ComparisonValue,
        lower_inclusive: bool,
        upper: ComparisonValue,
        upper_inclusive: bool,
    ) -> Result<Box<dyn Matcher<V>>, PathParseError> { ... }
}
Expand description

A Filter is a generic type that contains methods that are invoked by the build_filter function. Each method returns a heap-allocated Matcher<V> (typically a closure) containing logic to determine whether the value matches the filter. A filter is intended to be side-effect free and idempotent, and so only receives an immutable reference to self.

Required Methods§

Source

fn exists(&self, field: Field) -> Result<Box<dyn Matcher<V>>, PathParseError>

Determine whether a field value exists.

§Errors

Will return Err if the query contains an invalid path.

Source

fn equals( &self, field: Field, to_match: &str, ) -> Result<Box<dyn Matcher<V>>, PathParseError>

Determine whether a field value equals to_match.

§Errors

Will return Err if the query contains an invalid path.

Source

fn prefix( &self, field: Field, prefix: &str, ) -> Result<Box<dyn Matcher<V>>, PathParseError>

Determine whether a value starts with a prefix.

§Errors

Will return Err if the query contains an invalid path.

Source

fn wildcard( &self, field: Field, wildcard: &str, ) -> Result<Box<dyn Matcher<V>>, PathParseError>

Determine whether a value matches a wildcard.

§Errors

Will return Err if the query contains an invalid path.

Source

fn compare( &self, field: Field, comparator: Comparison, comparison_value: ComparisonValue, ) -> Result<Box<dyn Matcher<V>>, PathParseError>

Compare a field value against comparison_value, using one of the comparator operators.

§Errors

Will return Err if the query contains an invalid path.

Provided Methods§

Source

fn range( &self, field: Field, lower: ComparisonValue, lower_inclusive: bool, upper: ComparisonValue, upper_inclusive: bool, ) -> Result<Box<dyn Matcher<V>>, PathParseError>

Determine whether a field value falls within a range. By default, this will use self.compare on both the lower and upper bound.

§Errors

Will return Err if the query contains an invalid path.

Implementors§