Crates.io | get_dir |
lib.rs | get_dir |
version | 0.5.0 |
created_at | 2024-09-26 15:42:57.269723+00 |
updated_at | 2025-08-22 05:09:05.337567+00 |
description | A utility to get directory |
homepage | https://github.com/alpheusday/get_dir.rs |
repository | https://github.com/alpheusday/get_dir.rs |
max_upload_size | |
id | 1387673 |
size | 46,749 |
A utility to get directory.
This utility searches for a target directory by checking for any directories or files that match the provided input.
Get directory by target with the following code:
use std::path::PathBuf;
use get_dir::{
GetDir,
Target,
DirTarget,
};
let path: PathBuf = GetDir::new()
.target(
Target::Dir(DirTarget::new("src")),
)
.run()
.unwrap();
Or get directory by target in reverse with the following code:
use std::path::PathBuf;
use get_dir::{
GetDir,
Target,
FileTarget,
};
let path: PathBuf = GetDir::new()
.target(
Target::File(FileTarget::new("LICENSE")),
)
.run_reverse()
.unwrap();
Async version also available with async_std
, smol
and tokio
features:
use std::path::PathBuf;
use get_dir::{
GetDir,
Target,
DirTarget,
// async_std
async_std::GetDirAsyncExt,
// smol
smol::GetDirAsyncExt,
// tokio
tokio::GetDirAsyncExt,
};
let path: PathBuf = GetDir::new()
.target(
Target::Dir(DirTarget::new("src")),
)
.run_async()
.await
.unwrap();
For resolving the root of a workspace, consider using the workspace_root
library.
This project is licensed under the terms of the MIT license.