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///
20/// Use [`std::ops::ControlFlow::Continue`] to continue the traversal of changes.
21/// Use [`std::ops::ControlFlow::Break`] to stop the traversal of changes and stop calling the function that returned it.
22pub type Action = std::ops::ControlFlow<()>;
23
24/// Options for use in [`tree_with_rewrites()`](super::tree_with_rewrites()).
25#[derive(Default, Clone, Debug)]
26pub struct Options {
27    /// Determine how locations of changes, i.e. their repository-relative path, should be tracked.
28    /// If `None`, locations will always be empty.
29    pub location: Option<Location>,
30    /// If not `None`, rename tracking will be performed accordingly.
31    pub rewrites: Option<Rewrites>,
32}
33
34pub(super) mod function;