diff options
author | sharkdp <davidpeter@web.de> | 2019-09-21 11:37:46 +0200 |
---|---|---|
committer | sharkdp <davidpeter@web.de> | 2019-09-21 11:37:46 +0200 |
commit | a09b52204faeabe564e8890942f5b934db4e62a2 (patch) | |
tree | 79f6e7adb4a96e3c0265296f0e87f04ff7696329 | |
parent | 2f8f3628daae184c6e3b2ee0fc10bb48e58126be (diff) |
Make UniqueId private
-rw-r--r-- | src/walk/mod.rs | 9 | ||||
-rw-r--r-- | src/walk/unique_id.rs | 5 | ||||
-rw-r--r-- | src/walk/unix.rs | 7 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/walk/mod.rs b/src/walk/mod.rs index 87e4bcb..889eceb 100644 --- a/src/walk/mod.rs +++ b/src/walk/mod.rs @@ -5,11 +5,9 @@ use std::thread; use crossbeam_channel as channel; -use rayon; -use rayon::prelude::*; +use rayon::{self, prelude::*}; -#[derive(Eq, PartialEq, Hash)] -pub struct UniqueID(u64, u64); +mod unique_id; #[cfg(target_os = "windows")] mod windows; @@ -21,10 +19,13 @@ mod unix; #[cfg(not(target_os = "windows"))] pub use self::unix::*; +use unique_id::UniqueID; + pub enum Err { NoMetadataForPath(PathBuf), CouldNotReadDir(PathBuf), } + enum Message { SizeEntry(Option<UniqueID>, u64), Error { err: Err }, diff --git a/src/walk/unique_id.rs b/src/walk/unique_id.rs new file mode 100644 index 0000000..59d3cc2 --- /dev/null +++ b/src/walk/unique_id.rs @@ -0,0 +1,5 @@ +#[derive(Eq, PartialEq, Hash)] +pub struct UniqueID { + pub device: u64, + pub inode: u64, +} diff --git a/src/walk/unix.rs b/src/walk/unix.rs index f320fd1..6d918d7 100644 --- a/src/walk/unix.rs +++ b/src/walk/unix.rs @@ -1,13 +1,16 @@ use std::os::unix::fs::MetadataExt; -use super::UniqueID; +use crate::walk::unique_id::UniqueID; pub fn generate_unique_id(metadata: &std::fs::Metadata) -> Option<UniqueID> { // If the entry has more than one hard link, generate // a unique ID consisting of device and inode in order // not to count this entry twice. if metadata.is_file() && metadata.nlink() > 1 { - Some(UniqueID(metadata.dev(), metadata.ino())) + Some(UniqueID { + device: metadata.dev(), + inode: metadata.ino(), + }) } else { None } |