Skip to main content

Crate dirwalk

Crate dirwalk 

Source
Expand description

Platform-optimized recursive directory walker.

Captures file metadata (size, mtime, type) during enumeration without separate stat calls per entry.

§Quick start

use dirwalk::{WalkBuilder, Sort};

let result = WalkBuilder::new(".")
    .max_depth(3)
    .extensions(&["rs", "toml"])
    .sort(Sort::Name)
    .dirs_first(true)
    .stats(true)
    .build()
    .unwrap();

for entry in &result.entries {
    println!("{}", entry.relative_path);
}

if let Some(stats) = &result.stats {
    println!("{} files, {} dirs", stats.file_count, stats.dir_count);
}

§Architecture

The primary output is a flat Vec<Entry>. Tree structure is derived on demand via tree::to_tree.

Platform-specific scanning backends live in the scan module, dispatched at compile time via #[cfg(target_os)]. See that module’s docs for per-platform details.

WalkBuilder supports sequential (WalkIter) and parallel (Rayon) modes. Filters are applied during the walk, not post-hoc.

§Feature flags

FlagEffect
(default)Library only, no CLI dependencies.
serdeSerialize impl on Entry, pulls in serde + serde_json.
cliImplies serde, adds clap and csv for the dirwalk binary.

Re-exports§

pub use sort::Sort;

Modules§

group
Grouping utilities for walk results.
sort
Sorting for walk results.
tree
On-demand tree reconstruction from flat walk results.
util
Internal path utilities.

Structs§

Entry
A file or directory entry with metadata captured during enumeration.
Stats
Threads
Specifies parallelism for directory scanning.
WalkBuilder
Configures and executes a recursive directory walk.
WalkIter
WalkResult

Enums§

Error
StorageHint
Hint about the storage medium being walked.

Functions§

scan_dir
Scan a single directory, returning one Entry per item. Symlinks are included as entries but not followed. Returned entries have only the filename in relative_path and depth 0.
scan_dir_with_hint
Like scan_dir but accepts a StorageHint to tune platform-level I/O for local vs network-attached storage.