#async #walk #directory #recursive #stream

async-walkdir

Asynchronous directory traversal for Rust

2 unstable releases

0.2.0 Sep 7, 2020
0.1.0 Aug 31, 2020

#644 in Asynchronous

Download history 874/week @ 2023-01-21 472/week @ 2023-01-28 1750/week @ 2023-02-04 762/week @ 2023-02-11 610/week @ 2023-02-18 566/week @ 2023-02-25 755/week @ 2023-03-04 532/week @ 2023-03-11 718/week @ 2023-03-18 1064/week @ 2023-03-25 386/week @ 2023-04-01 430/week @ 2023-04-08 1152/week @ 2023-04-15 694/week @ 2023-04-22 976/week @ 2023-04-29 868/week @ 2023-05-06

3,715 downloads per month
Used in 11 crates (7 directly)

Apache-2.0

15KB
257 lines

Github CI docs.rs

async-walkdir

Asynchronous directory traversal for Rust.

Based on async-fs and blocking, it uses a thread pool to handle blocking IOs. Please refere to those crates for the rationale. This crate is compatible with any async runtime based on futures 0.3, which includes tokio, async-std and smol.

We do not plan to be as feature full as Walkdir crate in the synchronous world, but do not hesitate to open an issue or a PR.

Example

use async_walkdir::WalkDir;
use futures_lite::future::block_on;
use futures_lite::stream::StreamExt;

block_on(async {
    let mut entries = WalkDir::new("my_directory");
    loop {
        match entries.next().await {
            Some(Ok(entry)) => println!("file: {}", entry.path().display()),
            Some(Err(e)) => {
                eprintln!("error: {}", e);
                break;
            },
            None => break,
        }
    }
});

Dependencies

~1MB
~14K SLoC