git_diff/tree/
mod.rs

1use std::collections::VecDeque;
2
3use git_hash::ObjectId;
4use git_object::TreeRefIter;
5
6/// The state required to visit [Changes] to be instantiated with `State::default()`.
7#[derive(Default, Clone)]
8pub struct State {
9    buf1: Vec<u8>,
10    buf2: Vec<u8>,
11    trees: VecDeque<TreeInfoPair>,
12}
13
14type TreeInfoPair = (Option<ObjectId>, Option<ObjectId>);
15
16impl State {
17    fn clear(&mut self) {
18        self.trees.clear();
19        self.buf1.clear();
20        self.buf2.clear();
21    }
22}
23
24/// An iterator over changes of a tree, instantiated using `Changes::from(…)`.
25pub struct Changes<'a>(Option<TreeRefIter<'a>>);
26
27impl<'a, T> From<T> for Changes<'a>
28where
29    T: Into<Option<TreeRefIter<'a>>>,
30{
31    fn from(v: T) -> Self {
32        Changes(v.into())
33    }
34}
35
36///
37pub mod changes;
38
39///
40pub mod visit;
41#[doc(inline)]
42pub use visit::Visit;
43
44/// Useful for use as delegate implementing [`Visit`] to keep track of all seen changes. Useful for debugging or printing primarily.
45pub mod recorder;
46#[doc(inline)]
47pub use recorder::Recorder;