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
| Flag | Effect |
|---|---|
| (default) | Library only, no CLI dependencies. |
serde | Serialize impl on Entry, pulls in serde + serde_json. |
cli | Implies 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.
- Walk
Builder - Configures and executes a recursive directory walk.
- Walk
Iter - Walk
Result
Enums§
- Error
- Storage
Hint - Hint about the storage medium being walked.
Functions§
- scan_
dir - Scan a single directory, returning one
Entryper item. Symlinks are included as entries but not followed. Returned entries have only the filename inrelative_pathanddepth0. - scan_
dir_ with_ hint - Like
scan_dirbut accepts aStorageHintto tune platform-level I/O for local vs network-attached storage.