Expand description
duvis library surface.
The crate is shipped primarily as a CLI binary, but the same logic
is also reachable as a library. To keep refactors safe, only the
handful of items re-exported here are part of the stable public
surface — the internal module layout (scan/, classify/, entry/,
cli/, render/, wire/, filter/, ui/) is an implementation
detail and may change between minor versions.
Typical library use:
use duvis::{scan, HardlinkPolicy};
let (tree, counts) = scan(std::path::Path::new("."), HardlinkPolicy::CountOnce).unwrap();
println!("scanned {} items", counts.scanned());
if let Some(children) = tree.children() {
for child in children {
println!("{}", child.name);
}
}Binary use is just run_cli, which main.rs delegates to.
Structs§
- Classification
- Entry
- Scan
Counts - Live counters shared between the scanner and any observer.
items_scanneddrives the “12,345 items…” progress UI;items_skippedreports filesystem entries we could not read (permission denied, races against deletion, …) so the user can tell that the reported total is incomplete.
Enums§
- Category
- File / directory categorisation surfaced in the legend, in
--summary, and as the--categoryfilter values. - Classification
Reason - Why an entry was assigned a category. Surfaced via
--explain-categoryso anyone debugging “why is thiscache?” can see the rule that fired without reading the source. Wire form lives inwire::explain. - Entry
Kind - File or directory variant. Holding children inside the
Dirvariant makes “is this a directory?” and “does it have children?” the same question at the type level — earlier the two were modeled as separate fields (is_dir: bool+children: Option<Vec<Entry>>) and could in principle disagree. - Hardlink
Policy - How to attribute bytes when the same inode is reachable via multiple
hardlinked paths. Default matches
du— each inode counts once. Unix only; on Windows this knob has no effect because the stdMetadataAPI can’t surface a portable file id. - Sort
Order - How siblings are ordered for display.
Size(default) is largest-first before--reverseflips it;Nameis alphabetical. - Tier
- Whether a category is part of the always-shown core vocabulary or an extended category that only surfaces in the legend / sidebar when at least one entry of that category is actually present in the scan.
Functions§
- classify_
dir - Classify a directory by its name.
- classify_
file - Classify a file by its name (extension or, for a few special cases, full filename).
- explain_
dir - Same logic as
classify_dirbut also records which rule matched.classify_diris the thin wrapper used in the hot scanning path; this is the one called by--explain-categoryfor transparency. - explain_
file - Same logic as
classify_filebut also records which rule matched. - run_cli
- Binary entry.
main.rscalls this and returns the resulting exit code. All CLI / dispatch / exit-code work lives inside the lib crate so that downstream code (and integration tests) can drive the full pipeline without going through a subprocess. - scan
- Scan
pathto completion, returning the tree and the final counters (visited / skipped). Callers that need live progress should usescan_with_progressand observe a sharedScanCountsfrom another thread. - scan_
with_ progress - Same as
scanbut writes progress intocountsso a UI thread can poll the running totals while the scan is in flight.