Skip to main content

Crate duvis

Crate duvis 

Source
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
ScanCounts
Live counters shared between the scanner and any observer. items_scanned drives the “12,345 items…” progress UI; items_skipped reports 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 --category filter values.
ClassificationReason
Why an entry was assigned a category. Surfaced via --explain-category so anyone debugging “why is this cache?” can see the rule that fired without reading the source. Wire form lives in wire::explain.
EntryKind
File or directory variant. Holding children inside the Dir variant 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.
HardlinkPolicy
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 std Metadata API can’t surface a portable file id.
SortOrder
How siblings are ordered for display. Size (default) is largest-first before --reverse flips it; Name is 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_dir but also records which rule matched. classify_dir is the thin wrapper used in the hot scanning path; this is the one called by --explain-category for transparency.
explain_file
Same logic as classify_file but also records which rule matched.
run_cli
Binary entry. main.rs calls 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 path to completion, returning the tree and the final counters (visited / skipped). Callers that need live progress should use scan_with_progress and observe a shared ScanCounts from another thread.
scan_with_progress
Same as scan but writes progress into counts so a UI thread can poll the running totals while the scan is in flight.