Trait datafusion_common::tree_node::TreeNodeVisitor
source · pub trait TreeNodeVisitor: Sized {
type N: TreeNode;
// Required method
fn pre_visit(&mut self, node: &Self::N) -> Result<VisitRecursion>;
// Provided method
fn post_visit(&mut self, _node: &Self::N) -> Result<VisitRecursion> { ... }
}Expand description
Implements the visitor
pattern for recursively walking TreeNodes.
TreeNodeVisitor allows keeping the algorithms
separate from the code to traverse the structure of the TreeNode
tree and makes it easier to add new types of tree node and
algorithms.
When passed toTreeNode::visit, TreeNodeVisitor::pre_visit
and TreeNodeVisitor::post_visit are invoked recursively
on an node tree.
If an Err result is returned, recursion is stopped
immediately.
If VisitRecursion::Stop is returned on a call to pre_visit, no
children of that tree node are visited, nor is post_visit
called on that tree node
If VisitRecursion::Stop is returned on a call to post_visit, no
siblings of that tree node are visited, nor is post_visit
called on its parent tree node
If VisitRecursion::Skip is returned on a call to pre_visit, no
children of that tree node are visited.
Required Associated Types§
Required Methods§
sourcefn pre_visit(&mut self, node: &Self::N) -> Result<VisitRecursion>
fn pre_visit(&mut self, node: &Self::N) -> Result<VisitRecursion>
Invoked before any children of node are visited.
Provided Methods§
sourcefn post_visit(&mut self, _node: &Self::N) -> Result<VisitRecursion>
fn post_visit(&mut self, _node: &Self::N) -> Result<VisitRecursion>
Invoked after all children of node are visited. Default
implementation does nothing.