Transform your Rust development process with embd, a crate that simplifies file handling. In debug mode, seamlessly load files from the filesystem for quick edits, while in release mode, enjoy efficient embedding with no heap allocation. Perfect for developers seeking speed and efficiency without sacrificing ease of use.
embd-rs is a powerful and straightforward crate designed for file and directory embedding in Rust applications.
This crate streamlines the development process by allowing you to load files from the filesystem while in debug mode, making it perfect for rapid edit-and-test cycles without the need for recompilation. In release mode, embd-rs optimizes performance by embedding files directly into your binary without heap allocations, thus enhancing the efficiency of your application.
Key Features:
- Dynamic Loading: Load files during development for easy modifications and testing.
- Efficient Release Mode: Utilize Rust's powerful
include_str!
,include_bytes!
, and the custominclude_dir!
-like function to embed files, resulting in no heap allocation overhead.
How to Use embd-rs:
To get started, simply add the dependency to your Cargo.toml
:
[dependencies]
embd = "0.1"
Then, you can conveniently access your files and directories as shown in the example:
let contents: Cow<'_, str> = embd::string!("path/to/file.txt");
let bytes: Cow<'_, [u8]> = embd::bytes!("path/to/image.png");
let dir: embd::Dir = embd::dir!("path/to");
let files: Vec<embd::File> = dir.flatten();
For configuration, enable the procmacro2_semver_exempt
flag by adding the following to your .cargo/config.toml
:
[build]
rustflags = [ "--cfg", "procmacro2_semver_exempt" ]
Upcoming Features:
- Hot reloading of files in debug mode.
- Aiming to remove the dependency on
procmacro2_semver_exempt
.
Experience the best of both worlds in your Rust projects with embd-rs: develop swiftly in debug and optimize your performance in release!