| Crates.io | anydir-macro |
| lib.rs | anydir-macro |
| version | 0.1.0 |
| created_at | 2025-05-12 12:12:39.327779+00 |
| updated_at | 2025-05-12 12:12:39.327779+00 |
| description | A crate for working with both compile-time embedded directories and runtime directories using an abstraction. |
| homepage | |
| repository | https://github.com/arrowpc/anydir |
| max_upload_size | |
| id | 1670470 |
| size | 5,442 |
A Rust library that provides a unified interface for working with both compile-time embedded directories and runtime directories.
It frustrated me that no Rust library had an abstracted Dir type that allowed for both embedded compile-time directories and runtime directories, so I made one.
If you know of such a library, please let me know !
Add this to your Cargo.toml:
[dependencies]
anydir = "0.1.0"
use anydir::anydir;
fn main() {
// Embed files at compile time - bundled directly in your binary
let ct_dir = anydir!(ct, "$CARGO_MANIFEST_DIR");
let ct_files = ct_dir.list_files();
println!("Compile-time files: {:?}", ct_files);
// Access files at runtime from the filesystem
let rt_dir = anydir!(rt, "./");
let rt_files = rt_dir.list_files();
println!("Runtime files: {:?}", rt_files);
}
anydir!(ct, path) - Create a compile-time embedded directoryanydir!(rt, path) - Create a runtime directory referenceDirOps - Common operations for directories
list_files() - Returns a vector of filenames in the directory