Skip to content

Commit 1c201e3

Browse files
committed
feat(api): create some aliases
1 parent c2acc9f commit 1c201e3

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/hardlink/aware.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ use std::{fmt::Debug, os::unix::fs::MetadataExt};
1212
/// Deduplicate them (remove duplicated size) from total size to
1313
/// accurately reflect the real size of their containers.
1414
#[derive(Debug, Clone, Copy)]
15-
pub struct HardlinkAware<'a, Size> {
15+
pub struct Aware<'a, Size> {
1616
/// Map an inode number to its size and detected paths.
1717
record: &'a HardlinkList<Size>,
1818
}
1919

20-
impl<'a, Size> HardlinkAware<'a, Size> {
20+
pub use Aware as HardlinkAware;
21+
22+
impl<'a, Size> Aware<'a, Size> {
2123
/// Create a detector/recorder of hardlinks.
2224
pub fn new(record: &'a HardlinkList<Size>) -> Self {
23-
HardlinkAware { record }
25+
Aware { record }
2426
}
2527
}
2628

27-
impl<'a, Size, Report> RecordHardlinks<Size, Report> for HardlinkAware<'a, Size>
29+
impl<'a, Size, Report> RecordHardlinks<Size, Report> for Aware<'a, Size>
2830
where
2931
Size: size::Size + Eq + Debug,
3032
Report: Reporter<Size> + ?Sized,

src/hardlink/ignorant.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ use super::{RecordHardlinks, RecordHardlinksArgument};
44
/// Do not detect it. Do not deduplicate it.
55
/// Essentially no-op.
66
#[derive(Debug, Default, Clone, Copy)]
7-
pub struct HardlinkIgnorant;
7+
pub struct Ignorant;
8+
9+
pub use Ignorant as HardlinkIgnorant;
810

911
/// Do nothing to detect nor record any hardlink.
10-
impl<Size, Reporter> RecordHardlinks<Size, Reporter> for HardlinkIgnorant {
12+
impl<Size, Reporter> RecordHardlinks<Size, Reporter> for Ignorant {
1113
/// Do nothing.
1214
fn record_hardlinks(&self, _: RecordHardlinksArgument<Size, Reporter>) {}
1315
}

src/hardlink/record.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@ use std::{fs::Metadata, path::Path};
22

33
/// Argument to pass to [`RecordHardlinks::record_hardlinks`].
44
#[derive(Debug, Clone, Copy)]
5-
pub struct RecordHardlinksArgument<'a, Size, Report: ?Sized> {
5+
pub struct Argument<'a, Size, Report: ?Sized> {
66
pub path: &'a Path,
77
pub stats: &'a Metadata,
88
pub size: Size,
99
pub reporter: &'a Report,
1010
}
1111

12-
impl<'a, Size, Report: ?Sized> RecordHardlinksArgument<'a, Size, Report> {
12+
pub use Argument as RecordHardlinksArgument;
13+
14+
impl<'a, Size, Report: ?Sized> Argument<'a, Size, Report> {
1315
pub(crate) fn new(
1416
path: &'a Path,
1517
stats: &'a Metadata,
1618
size: Size,
1719
reporter: &'a Report,
1820
) -> Self {
19-
RecordHardlinksArgument {
21+
Argument {
2022
path,
2123
stats,
2224
size,
@@ -28,7 +30,7 @@ impl<'a, Size, Report: ?Sized> RecordHardlinksArgument<'a, Size, Report> {
2830
/// Ability to detect and record hardlinks.
2931
pub trait RecordHardlinks<Size, Reporter: ?Sized> {
3032
/// Perform hardlinks detection and recording.
31-
fn record_hardlinks(&self, argument: RecordHardlinksArgument<Size, Reporter>);
33+
fn record_hardlinks(&self, argument: Argument<Size, Reporter>);
3234
}
3335

3436
/// Do detect and record hardlinks.

0 commit comments

Comments
 (0)