Enum git_traverse::tree::visit::Action
source · pub enum Action {
Continue,
Cancel,
Skip,
}
Expand description
What to do after an entry was recorded.
Variants§
Continue
Continue the traversal of entries.
Cancel
Stop the traversal of entries, making this te last call to visit_(tree|nontree)(…)
.
Skip
Don’t dive into the entry, skipping children effectively. Only useful in visit_tree(…)
.
Implementations§
source§impl Action
impl Action
sourcepub fn cancelled(&self) -> bool
pub fn cancelled(&self) -> bool
Returns true if this action means to stop the traversal.
Examples found in repository?
src/tree/breadthfirst.rs (line 88)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
pub fn traverse<StateMut, Find, V>(
root: TreeRefIter<'_>,
mut state: StateMut,
mut find: Find,
delegate: &mut V,
) -> Result<(), Error>
where
Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Option<TreeRefIter<'a>>,
StateMut: BorrowMut<State>,
V: Visit,
{
let state = state.borrow_mut();
state.clear();
let mut tree = root;
loop {
for entry in tree {
let entry = entry?;
match entry.mode {
EntryMode::Tree => {
use crate::tree::visit::Action::*;
delegate.push_path_component(entry.filename);
let action = delegate.visit_tree(&entry);
match action {
Skip => {}
Continue => {
delegate.pop_path_component();
delegate.push_back_tracked_path_component(entry.filename);
state.next.push_back(entry.oid.to_owned())
}
Cancel => {
return Err(Error::Cancelled);
}
}
}
_non_tree => {
delegate.push_path_component(entry.filename);
if delegate.visit_nontree(&entry).cancelled() {
return Err(Error::Cancelled);
}
}
}
delegate.pop_path_component();
}
match state.next.pop_front() {
Some(oid) => {
delegate.pop_front_tracked_path_and_set_current();
match find(&oid, &mut state.buf) {
Some(tree_iter) => tree = tree_iter,
None => return Err(Error::NotFound { oid: oid.to_owned() }),
}
}
None => break Ok(()),
}
}
}
Trait Implementations§
source§impl Ord for Action
impl Ord for Action
source§impl PartialEq<Action> for Action
impl PartialEq<Action> for Action
source§impl PartialOrd<Action> for Action
impl PartialOrd<Action> for Action
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Action
impl Eq for Action
impl StructuralEq for Action
impl StructuralPartialEq for Action
Auto Trait Implementations§
impl RefUnwindSafe for Action
impl Send for Action
impl Sync for Action
impl Unpin for Action
impl UnwindSafe for Action
Blanket Implementations§
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more