1use std::collections::VecDeque;
2
3use bstr::BStr;
4use gix_hash::ObjectId;
5use gix_object::bstr::BString;
6
7use crate::tree::visit::Relation;
8
9#[derive(Debug, thiserror::Error)]
11#[allow(missing_docs)]
12pub enum Error {
13 #[error(transparent)]
14 Find(#[from] gix_object::find::existing_iter::Error),
15 #[error("The delegate cancelled the operation")]
16 Cancelled,
17 #[error(transparent)]
18 EntriesDecode(#[from] gix_object::decode::Error),
19}
20
21pub trait Visit {
24 fn pop_front_tracked_path_and_set_current(&mut self);
26 fn push_back_tracked_path_component(&mut self, component: &BStr);
28 fn push_path_component(&mut self, component: &BStr);
30 fn pop_path_component(&mut self);
32 fn visit(&mut self, change: visit::Change) -> visit::Action;
36}
37
38#[derive(Default, Clone)]
40pub struct State {
41 pub buf1: Vec<u8>,
43 pub buf2: Vec<u8>,
45 trees: VecDeque<TreeInfoTuple>,
46 change_id: visit::ChangeId,
47}
48
49type TreeInfoTuple = (Option<ObjectId>, Option<ObjectId>, Option<Relation>);
50
51impl State {
52 fn clear(&mut self) {
53 self.trees.clear();
54 self.buf1.clear();
55 self.buf2.clear();
56 self.change_id = 0;
57 }
58}
59
60pub(super) mod function;
61
62pub mod visit;
64
65#[derive(Clone, Debug)]
67pub struct Recorder {
68 path_deque: VecDeque<BString>,
69 path: BString,
70 location: Option<recorder::Location>,
71 pub records: Vec<recorder::Change>,
73}
74
75pub mod recorder;