History

[traverse-tree] more proper docs

Sebastian Thiel committed 5 years ago

Commit f66ccd31 parent f7eb3555 files · +15 −12Browse files

Unified · Split

5 files
  1. git-traverse/src/lib.rs +1 −1
  2. git-traverse/src/tree/breadthfirst.rs +8 −7
  3. git-traverse/src/tree/mod.rs +2 −0
  4. git-traverse/src/tree/visit.rs +3 −3
  5. git-traverse/tests/tree/mod.rs +1 −1
git-traverse/src/lib.rs+1−1
@@ -5,5 +5,5 @@ · 4 unmodified lines
55 /// Commit traversal
66 pub mod commit;
77
8−///
8+/// Tree traversal
99 pub mod tree;
git-traverse/src/tree/breadthfirst.rs+8−7
@@ -5,7 +5,7 @@ use quick_error::quick_error; · 4 unmodified lines
55 use std::{borrow::BorrowMut, collections::VecDeque};
66
77 quick_error! {
8− /// The error is part of the item returned by the [breadthfirst] function.
8+ /// The error is part of the item returned by the [`traverse()`] function.
99 #[derive(Debug)]
1010 #[allow(missing_docs)]
1111 pub enum Error {
@@ -37,18 +37,19 @@ impl<PathId: Clone> State<PathId> { · 25 unmodified lines
3737 }
3838 }
3939
40−/// Create a new instance.
40+/// Start a breadth-first iteration over the `root` trees entries.
4141 ///
42+/// * `root`
43+/// * the starting points of the iteration
44+/// * each commit they lead to will only be returned once, including the tip that started it
45+/// * `state` - all state used for the iteration. If multiple iterations are performed, allocations can be minimized by reusing
46+/// this state.
4247 /// * `find` - a way to lookup new object data during traversal by their ObjectId, writing their data into buffer and returning
4348 /// an iterator over entries if the object is present and is a tree. Caching should be implemented within this function
4449 /// as needed. The return value is `Option<TreeIter>` which degenerates all error information. Not finding a commit should also
4550 /// be considered an errors as all objects in the tree DAG should be present in the database. Hence [`Error::NotFound`] should
4651 /// be escalated into a more specific error if its encountered by the caller.
47−/// * `state` - all state used for the iteration. If multiple iterations are performed, allocations can be minimized by reusing
48−/// this state.
49−/// * `root`
50−/// * the starting points of the iteration
51−/// * each commit they lead to will only be returned once, including the tip that started it
52+/// * `delegate` - A way to observe entries and control the iteration while allowing the optimizer to let you pay only for what you use.
5253 pub fn traverse<StateMut, Find, V>(
5354 root: impl Into<ObjectId>,
5455 mut state: StateMut,
git-traverse/src/tree/mod.rs+2−0
@@ -8,3 +8,5 @@ pub use recorder::Recorder; · 7 unmodified lines
88
99 ///
1010 pub mod breadthfirst;
11+#[doc(inline)]
12+pub use breadthfirst::traverse as breadthfirst;
git-traverse/src/tree/visit.rs+3−3
@@ -1,14 +1,14 @@
11 use git_hash::bstr::BStr;
22 use git_object::immutable;
33
4−/// What to do after an entry was [recorded][Visit::visit()].
4+/// What to do after an entry was [recorded][Visit::visit_tree()].
55 #[derive(Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)]
66 pub enum Action {
77 /// Continue the traversal of entries.
88 Continue,
9− /// Stop the traversal of entries, making this te last call to [visit(…)][Visit::visit()].
9+ /// Stop the traversal of entries, making this te last call to [`visit_(tree|nontree)(…)`][Visit::visit_nontree()].
1010 Cancel,
11− /// Don't dive into the entry, skipping children effectively.
11+ /// Don't dive into the entry, skipping children effectively. Only useful in [`visit_tree(…)`][Visit::visit_tree()].
1212 Skip,
1313 }
1414
git-traverse/tests/tree/mod.rs+1−1
@@ -22,7 +22,7 @@ fn basic_nesting() -> crate::Result<()> { · 21 unmodified lines
2222 .into_commit_iter()
2323 .expect("commit present");
2424 let mut recorder = tree::Recorder::default();
25− tree::breadthfirst::traverse(
25+ git_traverse::tree::breadthfirst(
2626 commit.tree_id().expect("a tree is available in a commit"),
2727 tree::breadthfirst::State::default(),
2828 |oid, buf| {