parallel_disk_usage/hardlink/
ignorant.rs

1use super::{DeduplicateSharedSize, RecordHardlinks, RecordHardlinksArgument};
2use crate::{data_tree::DataTree, os_string_display::OsStringDisplay, size};
3use std::convert::Infallible;
4
5/// Be ignorant of hardlinks. Treat them as real files.
6/// Do not detect it. Do not deduplicate it.
7/// Essentially no-op.
8#[derive(Debug, Default, Clone, Copy)]
9pub struct Ignorant;
10
11pub use Ignorant as HardlinkIgnorant;
12
13/// Do nothing to detect nor record any hardlink.
14impl<Size, Reporter> RecordHardlinks<Size, Reporter> for Ignorant {
15    /// Doing nothing cannot fail.
16    type Error = Infallible;
17
18    /// Do nothing.
19    #[inline]
20    fn record_hardlinks(
21        &self,
22        _: RecordHardlinksArgument<Size, Reporter>,
23    ) -> Result<(), Self::Error> {
24        Ok(())
25    }
26}
27
28/// Do nothing to deduplicate the sizes of hardlinks.
29impl<Size> DeduplicateSharedSize<Size> for HardlinkIgnorant
30where
31    Size: size::Size + Sync,
32{
33    /// Return nothing.
34    type Report = ();
35    /// Doing nothing cannot fail.
36    type Error = Infallible;
37
38    /// Do nothing.
39    #[inline]
40    fn deduplicate(
41        self,
42        _: &mut DataTree<OsStringDisplay, Size>,
43    ) -> Result<Self::Report, Self::Error> {
44        Ok(())
45    }
46}