gix_diff/tree_with_rewrites/
mod.rs

1use crate::tree::recorder::Location;
2use crate::Rewrites;
3
4mod change;
5pub use change::{Change, ChangeRef};
6
7/// The error returned by [`tree_with_rewrites()`](super::tree_with_rewrites()).
8#[derive(Debug, thiserror::Error)]
9#[allow(missing_docs)]
10pub enum Error {
11    #[error(transparent)]
12    Diff(#[from] crate::tree::Error),
13    #[error("The user-provided callback failed")]
14    ForEach(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
15    #[error("Failure during rename tracking")]
16    RenameTracking(#[from] crate::rewrites::tracker::emit::Error),
17}
18
19/// Returned by the [`tree_with_rewrites()`](super::tree_with_rewrites()) function to control flow.
20#[derive(Default, Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)]
21pub enum Action {
22    /// Continue the traversal of changes.
23    #[default]
24    Continue,
25    /// Stop the traversal of changes and stop calling the function that returned it.
26    Cancel,
27}
28
29/// Options for use in [`tree_with_rewrites()`](super::tree_with_rewrites()).
30#[derive(Default, Clone, Debug)]
31pub struct Options {
32    /// Determine how locations of changes, i.e. their repository-relative path, should be tracked.
33    /// If `None`, locations will always be empty.
34    pub location: Option<Location>,
35    /// If not `None`, rename tracking will be performed accordingly.
36    pub rewrites: Option<Rewrites>,
37}
38
39pub(super) mod function;