parallel_disk_usage/hardlink/
deduplicate.rs

1use crate::{data_tree::DataTree, os_string_display::OsStringDisplay, size};
2
3/// Ability to correct the sizes in a [`DataTree`] by reducing the size of recorded shared links.
4///
5/// The input tree is assumed to be not yet deduplicated.
6pub trait DeduplicateSharedSize<Size: size::Size>: Sized {
7    /// Report returned when [`DeduplicateSharedSize::deduplicate`] succeeds.
8    type Report;
9    /// Error returned when [`DeduplicateSharedSize::deduplicate`] fails.
10    type Error;
11    /// Correct the sizes in a [`DataTree`] by reducing the size of recorded shared links.
12    fn deduplicate(
13        self,
14        data_tree: &mut DataTree<OsStringDisplay, Size>,
15    ) -> Result<Self::Report, Self::Error>;
16}
17
18/// Do deduplicate the sizes of hardlinks.
19#[cfg(unix)]
20pub type Do<Size> = super::HardlinkAware<Size>;
21/// Do not deduplicate the sizes of hardlinks.
22pub type DoNot = super::HardlinkIgnorant;