Function async_std::fs::read_dir[][src]

pub async fn read_dir<P: AsRef<Path>>(path: P) -> Result<ReadDir>

Returns a stream of entries in a directory.

The stream yields items of type io::Result<DirEntry>. Note that I/O errors can occur while reading from the stream.

This function is an async version of std::fs::read_dir.

Errors

An error will be returned in the following situations:

Examples

use async_std::fs;
use async_std::prelude::*;

let mut entries = fs::read_dir(".").await?;

while let Some(res) = entries.next().await {
    let entry = res?;
    println!("{}", entry.file_name().to_string_lossy());
}