Expand description
§Get Dir
A utility to get directory.
This utility searches for a target directory by checking for any directories or files that match the provided input.
§Usage
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();
Modules§
- async_
std - Run asynchronously with
async_std
feature. - smol
- Run asynchronously with
smol
feature. - tokio
- Run asynchronously with
tokio
feature.
Structs§
- DirTarget
- Directory target struct.
- File
Target - File target struct.
- GetDir
- Utility to get directory.
Enums§
- Target
- Enum to determine whether the target is a directory or a file.