Skip to main content

PredicateVisitor

Trait PredicateVisitor 

Source
pub trait PredicateVisitor {
    type Error;
    type Value;

    // Required methods
    fn visit_leaf(
        &mut self,
        leaf: &PredicateNode,
    ) -> Result<VisitOutcome<Self::Value>, Self::Error>;
    fn combine_not(
        &mut self,
        original: &Predicate,
        child: VisitOutcome<Self::Value>,
    ) -> Result<VisitOutcome<Self::Value>, Self::Error>;
    fn combine_and(
        &mut self,
        original: &Predicate,
        children: Vec<VisitOutcome<Self::Value>>,
    ) -> Result<VisitOutcome<Self::Value>, Self::Error>;
    fn combine_or(
        &mut self,
        original: &Predicate,
        children: Vec<VisitOutcome<Self::Value>>,
    ) -> Result<VisitOutcome<Self::Value>, Self::Error>;

    // Provided methods
    fn visit_predicate(
        &mut self,
        predicate: &Predicate,
    ) -> Result<VisitOutcome<Self::Value>, Self::Error> { ... }
    fn visit_node(
        &mut self,
        node: &PredicateNode,
        original: &Predicate,
    ) -> Result<VisitOutcome<Self::Value>, Self::Error> { ... }
}
Expand description

Visitor that walks predicate trees and emits custom results plus residual predicates.

Required Associated Types§

Source

type Error

Error type used when evaluation fails.

Source

type Value

Concrete value type produced while walking the predicate.

Required Methods§

Source

fn visit_leaf( &mut self, leaf: &PredicateNode, ) -> Result<VisitOutcome<Self::Value>, Self::Error>

Evaluates a leaf predicate and returns its result.

Source

fn combine_not( &mut self, original: &Predicate, child: VisitOutcome<Self::Value>, ) -> Result<VisitOutcome<Self::Value>, Self::Error>

Combines the result of a negated child predicate.

Source

fn combine_and( &mut self, original: &Predicate, children: Vec<VisitOutcome<Self::Value>>, ) -> Result<VisitOutcome<Self::Value>, Self::Error>

Combines an AND clause from the supplied child results.

Source

fn combine_or( &mut self, original: &Predicate, children: Vec<VisitOutcome<Self::Value>>, ) -> Result<VisitOutcome<Self::Value>, Self::Error>

Combines an OR clause from the supplied child results.

Provided Methods§

Source

fn visit_predicate( &mut self, predicate: &Predicate, ) -> Result<VisitOutcome<Self::Value>, Self::Error>

Visits the supplied predicate by walking the expression tree.

Source

fn visit_node( &mut self, node: &PredicateNode, original: &Predicate, ) -> Result<VisitOutcome<Self::Value>, Self::Error>

Internal helper that evaluates a predicate node recursively.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§