duplicates/lib.rs
1//! This crate can be used to detect and report duplicate files in a file
2//! system.
3//!
4//! The functions in [`duplicates`] can be used to get a list of lists of
5//! duplicate file paths. [`duplicates::get_duplicates_hashed`] should
6//! generally be preferred, since it uses memory proportional to the size of
7//! the largest file, independent of how many files are being checked.
8//!
9//! The function [`paths::get_descendants`] is convenient for getting the list of
10//! all files which are descendants of a base path.
11//!
12//! ## Basic usage:
13//! ```no_run
14//! // Assume the following directory structure, where the contents of
15//! // a.txt and e.txt are identical, and the contents of b.txt, c.txt, and
16//! // d.txt are identical.
17//! //
18//! // files
19//! // ├── a.txt
20//! // ├── b.txt
21//! // └── more_files
22//! // ├── c.txt
23//! // ├── d.txt
24//! // └── even_more_files
25//! // ├── e.txt
26//! // └── f.txt
27//!
28//! let base_path = Path::from("files");
29//! let descendants = get_descendants(base_path);
30//! let duplicates = get_duplicates_hashed(&descendants);
31//! let expected = vec![
32//! vec!["files/a.txt", "files/more_files/even_more_files/e.txt"],
33//! vec!["files/b.txt", "files/more_files/c.txt", "files/more_files.d.txt"]
34//! ];
35//! assert!(duplicates == expected);
36//! ```
37
38pub mod duplicates;
39pub mod paths;