dirscent 0.1.0

Directory descent
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented2 out of 3 items with examples
  • Size
  • Source code size: 48.37 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.76 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xmyst

dirscent — directory descent

dirscent provides a simple and efficient iterator over the entries of a directory, and, recursively, over the entries of all subdirectories.

Install

Add the dependency to your Cargo.toml

[dependencies]
dirscent = "0.1"

Or from the command line

% cargo add dirscent@0.1

Usage

Iterate down the hierarchy skipping the entries for which the process does not have permissions

use dirscent::dirscent;

fn main() {
    for it in dirscent("/usr")
        .unwrap()
        .postorder()
        .skip_permission_denied()
    {
        match it {
            Ok(entry) => println!("{}", entry.path().display()),
            Err(err) => eprintln!("{err:?}"),
        }
    }
}

Performance

On my system, dirscent is 1.5× faster than fts(3) and 2× faster than find(1). Run benches/b.sh and see for yourself.