ZipperMoving
Some zippers allow the focus to be moved, which is done using the methods in the ZipperMoving trait. It is almost always faster to move a zipper's focus than to create a new zipper. Moving to a longer path is called descending while moving to a shorter path is called ascending.
The ZipperMoving trait provides methods to navigate through the trie. It provides both fine-grained single-step movement and higher-level jumping methods.
Descending is not limited in any way, and moving the focus to non-existent paths is one of the ways new paths are created by zippers with writing capability. When ascending, the zipper's focus cannot be moved above the zipper's root. The root is the highest possible position for the zipper's focus.
Reset and the Root Position
resetmoves the focus back to the zipper's root.at_rootchecks if the zipper is at its root position.
Absolute Positioning
move_to_pathmoves the zipper's focus directly to a specific path relative to the zipper's root.
Stepping vs. Jumping
Zippers may be descended and ascended either by stepping an absolute number of elements, or by jumping to features such as branches, values, or the end of the path. In general, moving by jumping will be faster than stepping.
Stepping Methods
These methods move the zipper by specific byte distances
descend_to_bytedescends down one level to the specified child bytedescend_indexed_bytedescends one byte to the nth child branch (by index in the child mask)descend_first_bytemoves down to the first child branchascendmoves up a specified number of bytes toward the rootascend_bytemoves up exactly one byte (equivalent toascend(1))
Jumping Methods
These methods move the zipper to positions based on trie features:
descend_tomoves to a path relative to the current focus positiondescend_to_existingfollows a path, stopping if a non-existent path byte is encountereddescend_to_valsimilar todescend_to_existingbut also stops if a value is encountereddescend_untildescends until a position with multiple children or a value is encounteredascend_untilascends until reaching a position with multiple children, a value, or the rootascend_until_branchascends until reaching a position with multiple children, skipping values
Sibling Navigation
to_next_sibling_bytemoves to the next sibling at the current levelto_prev_sibling_bytemoves to the previous sibling at the current level