NodeFolderContext

Trait NodeFolderContext 

Source
pub trait NodeFolderContext {
    type NodeTy: Node;
    type Result;
    type Context;

    // Required methods
    fn visit_down(
        &mut self,
        _ctx: &Self::Context,
        _node: &Self::NodeTy,
    ) -> VortexResult<FoldDownContext<Self::Context, Self::Result>>;
    fn visit_up(
        &mut self,
        _node: Self::NodeTy,
        _context: &Self::Context,
        _children: Vec<Self::Result>,
    ) -> VortexResult<FoldUp<Self::Result>>;
}
Expand description

Use to implement the folding a tree like structure in a pre-order traversal.

At each point on the way down, the visit_down method is called. If it returns Skip, the children of the current node are skipped. If it returns Stop, the fold is stopped. If it returns Continue, the children of the current node are visited.

At each point on the way up, the visit_up method is called. If it returns Stop, the fold stops.

On the way up the folded children are passed to the visit_up method along with the current node.

Note: this trait is not safe to use for graphs with a cycle.

Required Associated Types§

Required Methods§

Source

fn visit_down( &mut self, _ctx: &Self::Context, _node: &Self::NodeTy, ) -> VortexResult<FoldDownContext<Self::Context, Self::Result>>

visit_down is called when a node is first encountered, in a pre-order traversal. If the node’s children are to be skipped, return Skip. If the node should stop traversal, return Stop. Otherwise, return Continue.

Source

fn visit_up( &mut self, _node: Self::NodeTy, _context: &Self::Context, _children: Vec<Self::Result>, ) -> VortexResult<FoldUp<Self::Result>>

visit_up is called when a node is last encountered, in a pre-order traversal. If the node should stop traversal, return Stop. Otherwise, return Continue.

Implementors§