Skip to content

Commit b4477d5

Browse files
committed
docs(hardlink): address review feedback on doc comments and error attrs
- Trim InodeKey doc to a single line (remove over-explanation) - Restore doc style for SizeConflictError and NumberOfLinksConflictError with `ino`, `dev`, and `nlink` links to MetadataExt methods - Rephrase Reflection guarantee as "pair of an inode number and a device number" - Remove unnecessary #[error(not(source))] on DuplicatedInode tuple variant (derive_more only auto-assumes source for single-field variants) https://claude.ai/code/session_01QP9wZyoZcGmJsEsA66ZRok
1 parent 9a16e84 commit b4477d5

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/hardlink/hardlink_list.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ use pipe_trait::Pipe;
2121
use std::path::Path;
2222

2323
/// Internal key used to uniquely identify an inode across all filesystems.
24-
///
25-
/// Hardlinks cannot span filesystems, so including the device number prevents
26-
/// false deduplication of files from different filesystems that happen to share
27-
/// the same inode number. Both du-dust and dua-cli track `(device, inode)` pairs
28-
/// for the same reason.
2924
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
3025
struct InodeKey {
3126
/// Inode number within the device.
@@ -78,7 +73,10 @@ impl<Size> HardlinkList<Size> {
7873
}
7974
}
8075

81-
/// Error that occurs when a different size was detected for the same inode.
76+
/// Error that occurs when a different size was detected for the same [`ino`] and [`dev`].
77+
///
78+
/// [`ino`]: std::os::unix::fs::MetadataExt::ino
79+
/// [`dev`]: std::os::unix::fs::MetadataExt::dev
8280
#[derive(Debug, Display, Error)]
8381
#[cfg_attr(test, derive(PartialEq, Eq))]
8482
#[display(bound(Size: Debug))]
@@ -90,7 +88,11 @@ pub struct SizeConflictError<Size> {
9088
pub detected: Size,
9189
}
9290

93-
/// Error that occurs when a different number of links was detected for the same inode.
91+
/// Error that occurs when a different [`nlink`] was detected for the same [`ino`] and [`dev`].
92+
///
93+
/// [`nlink`]: std::os::unix::fs::MetadataExt::nlink
94+
/// [`ino`]: std::os::unix::fs::MetadataExt::ino
95+
/// [`dev`]: std::os::unix::fs::MetadataExt::dev
9496
#[derive(Debug, Display, Error)]
9597
#[cfg_attr(test, derive(PartialEq, Eq))]
9698
#[display(

src/hardlink/hardlink_list/reflection.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
1212
/// internal content.
1313
///
1414
/// **Guarantees:**
15-
/// * Every `(device, inode)` pair is unique.
15+
/// * Every pair of an inode number and a device number is unique.
1616
/// * The internal list is always sorted by inode numbers (with device number as tie-breaker).
1717
///
1818
/// **Equality:** `Reflection` implements `PartialEq` and `Eq` traits.
@@ -113,10 +113,7 @@ impl<Size> From<HardlinkList<Size>> for Reflection<Size> {
113113
pub enum ConversionError {
114114
/// When the source has a duplicated `(inode, device)` pair.
115115
#[display("Inode {_0} on device {_1} is duplicated")]
116-
DuplicatedInode(
117-
#[error(not(source))] InodeNumber,
118-
#[error(not(source))] DeviceNumber,
119-
),
116+
DuplicatedInode(InodeNumber, DeviceNumber),
120117
}
121118

122119
impl ConversionError {

0 commit comments

Comments
 (0)