gix_diff/tree_with_rewrites/
mod.rs

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