Function filetools::list_directories
source · pub async fn list_directories<P: AsRef<Path> + Send>(
path: P
) -> Result<Vec<PathBuf>>
Expand description
Lists all directories in the given directory (not including subdirectories).
§Sync
For the sync
version, see crate::sync::list_directories
§Errors
This function will return an error in the following situations:
- The given path is a file and not a directory
- The given path does not exist
§Example
use filetools::list_directories;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let target_folder = "directory/containing/other/directories";
// Will return a Vec containing all directories in the folder
let directories = list_directories(target_folder).await?;
Ok(())
}