ZipperMoving

Trait ZipperMoving 

Source
pub trait ZipperMoving: Zipper {
Show 24 methods // Required methods fn path(&self) -> &[u8] ; fn val_count(&self) -> usize; fn descend_to<K: AsRef<[u8]>>(&mut self, k: K); fn ascend(&mut self, steps: usize) -> bool; fn ascend_until(&mut self) -> bool; fn ascend_until_branch(&mut self) -> bool; // Provided methods fn at_root(&self) -> bool { ... } fn reset(&mut self) { ... } fn move_to_path<K: AsRef<[u8]>>(&mut self, path: K) -> usize { ... } fn descend_to_check<K: AsRef<[u8]>>(&mut self, k: K) -> bool { ... } fn descend_to_existing<K: AsRef<[u8]>>(&mut self, k: K) -> usize { ... } fn descend_to_val<K: AsRef<[u8]>>(&mut self, k: K) -> usize { ... } fn descend_to_value<K: AsRef<[u8]>>(&mut self, k: K) -> usize { ... } fn descend_to_byte(&mut self, k: u8) { ... } fn descend_to_existing_byte(&mut self, k: u8) -> bool { ... } fn descend_indexed_byte(&mut self, idx: usize) -> bool { ... } fn descend_indexed_branch(&mut self, idx: usize) -> bool { ... } fn descend_first_byte(&mut self) -> bool { ... } fn descend_last_byte(&mut self) -> bool { ... } fn descend_until(&mut self) -> bool { ... } fn ascend_byte(&mut self) -> bool { ... } fn to_next_sibling_byte(&mut self) -> bool { ... } fn to_prev_sibling_byte(&mut self) -> bool { ... } fn to_next_step(&mut self) -> bool { ... }
}
Expand description

An interface to enable moving a zipper around the trie and inspecting paths

§Terminology:

A zipper’s root is a point in the trie above which the zipper cannot ascend. A zipper permits access to a subtrie descending from its root, but that subtrie may be a part of a supertrie that the zipper is unable to access.

A zipper’s origin is always equal-to-or-above the zipper’s root. The position of the origin depends on how the zipper was created, and the origin will never be below the root. The origin of a given zipper will never change.

Required Methods§

Source

fn path(&self) -> &[u8]

Returns the path from the zipper’s root to the current focus

Source

fn val_count(&self) -> usize

Returns the total number of values contained at and below the zipper’s focus, including the focus itself

WARNING: This is not a cheap method. It may have an order-N cost

Source

fn descend_to<K: AsRef<[u8]>>(&mut self, k: K)

Moves the zipper deeper into the trie, to the key specified relative to the current zipper focus

Source

fn ascend(&mut self, steps: usize) -> bool

Ascends the zipper steps steps. Returns true if the zipper sucessfully moved steps

If the root is fewer than n steps from the zipper’s position, then this method will stop at the root and return false

Source

fn ascend_until(&mut self) -> bool

Ascends the zipper to the nearest upstream branch point or value. Returns true if the zipper focus moved upwards, otherwise returns false if the zipper was already at the root

NOTE: A default implementation could be provided, but all current zippers have more optimal native implementations.

Source

fn ascend_until_branch(&mut self) -> bool

Ascends the zipper to the nearest upstream branch point, skipping over values along the way. Returns true if the zipper focus moved upwards, otherwise returns false if the zipper was already at the root

NOTE: A default implementation could be provided, but all current zippers have more optimal native implementations.

Provided Methods§

Source

fn at_root(&self) -> bool

Returns true if the zipper’s focus is at its root, and it cannot ascend further, otherwise returns false

Source

fn reset(&mut self)

Resets the zipper’s focus back to its root

Source

fn move_to_path<K: AsRef<[u8]>>(&mut self, path: K) -> usize

Moves the zipper’s focus to a specific location specified by path, relative to the zipper’s root

Returns the number of bytes shared between the old and new location

Source

fn descend_to_check<K: AsRef<[u8]>>(&mut self, k: K) -> bool

Fused descend_to and path_exists. Moves the focus and returns whether or not the path exists at the new focus location

Source

fn descend_to_existing<K: AsRef<[u8]>>(&mut self, k: K) -> usize

Moves the zipper deeper into the trie, following the path specified by k, relative to the current zipper focus. Descent stops at the point where the path does not exist

Returns the number of bytes descended along the path. The zipper’s focus will always be on an existing path after this method returns, unless the method was called with the focus on a non-existent path.

Source

fn descend_to_val<K: AsRef<[u8]>>(&mut self, k: K) -> usize

Moves the zipper deeper into the trie, following the path specified by k, relative to the current zipper focus. Descent stops if a value is encountered or if the path ceases to exist.

Returns the number of bytes descended along the path.

If the focus is already on a value, this method will descend to the next value along the path.

Source

fn descend_to_value<K: AsRef<[u8]>>(&mut self, k: K) -> usize

👎Deprecated

Deprecated alias for ZipperMoving::descend_to_val

Source

fn descend_to_byte(&mut self, k: u8)

Moves the zipper one byte deeper into the trie. Identical in effect to descend_to with a 1-byte key argument

Source

fn descend_to_existing_byte(&mut self, k: u8) -> bool

Moves the zipper one byte deeper into the trie, if the specified path byte exists in the child_mask.

Returns true if the zipper’s focus moved and false if it is still at the original location.

Source

fn descend_indexed_byte(&mut self, idx: usize) -> bool

Descends the zipper’s focus one byte into a child branch uniquely identified by child_idx

child_idx must within the range 0..child_count() or this method will do nothing and return false

WARNING: The branch represented by a given index is not guaranteed to be stable across modifications to the trie. This method should only be used as part of a directed traversal operation, but index-based paths may not be stored as locations within the trie.

Source

fn descend_indexed_branch(&mut self, idx: usize) -> bool

👎Deprecated

A deprecated alias for ZipperMoving::descend_indexed_byte

Source

fn descend_first_byte(&mut self) -> bool

Descends the zipper’s focus one step into the first child branch in a depth-first traversal

NOTE: This method should have identical behavior to passing 0 to descend_indexed_byte, although with less overhead

Source

fn descend_last_byte(&mut self) -> bool

Descends the zipper’s focus one step into the last child branch

NOTE: This method should have identical behavior to passing child_count() - 1 to descend_indexed_byte, although with less overhead

Source

fn descend_until(&mut self) -> bool

Descends the zipper’s focus until a branch or a value is encountered. Returns true if the focus moved otherwise returns false

If there is a value at the focus, the zipper will descend to the next value or branch, however the zipper will not descend further if this method is called with the focus already on a branch.

Does nothing and returns false if the zipper’s focus is on a non-existent path.

Source

fn ascend_byte(&mut self) -> bool

Ascends the zipper up a single byte. Equivalent to passing 1 to ascend

Source

fn to_next_sibling_byte(&mut self) -> bool

Moves the zipper’s focus to the next sibling byte with the same parent

Returns true if the focus was moved. If the focus is already on the last byte among its siblings, this method returns false, leving the focus unmodified.

This method is equivalent to calling ZipperMoving::ascend with 1, followed by ZipperMoving::descend_indexed_byte where the index passed is 1 more than the index of the current focus position.

Source

fn to_prev_sibling_byte(&mut self) -> bool

Moves the zipper’s focus to the previous sibling byte with the same parent

Returns true if the focus was moved. If the focus is already on the first byte among its siblings, this method returns false, leving the focus unmodified.

This method is equivalent to calling Self::ascend with 1, followed by Self::descend_indexed_byte where the index passed is 1 less than the index of the current focus position.

Source

fn to_next_step(&mut self) -> bool

Advances the zipper to visit every existing path within the trie in a depth-first order

Returns true if the position of the zipper has moved, or false if the zipper has returned to the root

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<Z> ZipperMoving for &mut Z
where Z: ZipperMoving + Zipper,

Source§

fn at_root(&self) -> bool

Source§

fn reset(&mut self)

Source§

fn path(&self) -> &[u8]

Source§

fn val_count(&self) -> usize

Source§

fn descend_to<K: AsRef<[u8]>>(&mut self, k: K)

Source§

fn descend_to_check<K: AsRef<[u8]>>(&mut self, k: K) -> bool

Source§

fn descend_to_existing<K: AsRef<[u8]>>(&mut self, k: K) -> usize

Source§

fn descend_to_val<K: AsRef<[u8]>>(&mut self, k: K) -> usize

Source§

fn descend_to_byte(&mut self, k: u8)

Source§

fn descend_to_existing_byte(&mut self, k: u8) -> bool

Source§

fn descend_indexed_byte(&mut self, idx: usize) -> bool

Source§

fn descend_first_byte(&mut self) -> bool

Source§

fn descend_until(&mut self) -> bool

Source§

fn ascend(&mut self, steps: usize) -> bool

Source§

fn ascend_byte(&mut self) -> bool

Source§

fn ascend_until(&mut self) -> bool

Source§

fn ascend_until_branch(&mut self) -> bool

Source§

fn to_next_sibling_byte(&mut self) -> bool

Source§

fn to_prev_sibling_byte(&mut self) -> bool

Source§

fn to_next_step(&mut self) -> bool

Implementors§

Source§

impl ZipperMoving for EmptyZipper

Source§

impl<'a, 'path, V: Clone + Send + Sync + Unpin, A: Allocator + 'a> ZipperMoving for WriteZipperTracked<'a, 'path, V, A>

Source§

impl<'a, 'path, V: Clone + Send + Sync + Unpin, A: Allocator + 'a> ZipperMoving for WriteZipperUntracked<'a, 'path, V, A>

Source§

impl<'prefix, Z> ZipperMoving for PrefixZipper<'prefix, Z>
where Z: ZipperMoving,

Source§

impl<'trie, PrimaryZ, SecondaryZ, V> ZipperMoving for ProductZipperG<'trie, PrimaryZ, SecondaryZ, V>
where V: Clone + Send + Sync, PrimaryZ: ZipperMoving, SecondaryZ: ZipperMoving,

Source§

impl<'trie, PrimaryZ, SecondaryZ, V, C, F: Clone + for<'a> FnOnce(C, &'a [u8], usize) -> (C, Option<SecondaryZ>)> ZipperMoving for DependentProductZipperG<'trie, PrimaryZ, SecondaryZ, V, C, F>
where V: Clone + Send + Sync, PrimaryZ: ZipperMoving, SecondaryZ: ZipperMoving,

Source§

impl<'trie, V: Clone + Send + Sync + Unpin + 'trie, A: Allocator + 'trie> ZipperMoving for ProductZipper<'_, 'trie, V, A>

Source§

impl<'trie, V: Clone + Send + Sync + Unpin + 'trie, A: Allocator + 'trie> ZipperMoving for ReadZipperTracked<'trie, '_, V, A>

Source§

impl<'trie, V: Clone + Send + Sync + Unpin + 'trie, A: Allocator + 'trie> ZipperMoving for ReadZipperUntracked<'trie, '_, V, A>

Source§

impl<A: Zipper + ZipperMoving, B: Zipper + ZipperMoving> ZipperMoving for DiffZipper<A, B>

Source§

impl<AV, BV, OutV, AZipper, BZipper, Mapping> ZipperMoving for OverlayZipper<AV, BV, OutV, AZipper, BZipper, Mapping>
where AZipper: ZipperMoving + ZipperValues<AV>, BZipper: ZipperMoving + ZipperValues<BV>, Mapping: for<'a> Fn(Option<&'a AV>, Option<&'a BV>) -> Option<&'a OutV>,

Source§

impl<V: Clone + Send + Sync + Unpin, A: Allocator> ZipperMoving for ReadZipperOwned<V, A>

Source§

impl<V: Clone + Send + Sync + Unpin, A: Allocator> ZipperMoving for WriteZipperOwned<V, A>

Source§

impl<Z: ZipperMoving> ZipperMoving for OneFactor<Z>