| Crates.io | include-fs |
| lib.rs | include-fs |
| version | 0.2.0 |
| created_at | 2025-05-26 12:39:32.237105+00 |
| updated_at | 2025-05-29 22:41:16.689748+00 |
| description | Embed folders in your binary |
| homepage | |
| repository | https://github.com/happenslol/include-fs |
| max_upload_size | |
| id | 1689520 |
| size | 27,374 |
include-fs allows embedding entire directories into binaries at compile time, similar to how include_bytes! and include_str! work for single files. The library packages directories into an archive, embeds the archive using include_bytes!, and allows accessing the files by path at runtime.
build.rs)fn main() {
include_fs::embed_fs("src/assets", "assets").unwrap();
}
static ASSETS: IncludeFs = include_fs!("assets");
fn main() {
let image_exists = ASSETS.exists("assets/image.jpg");
let config_content = ASSETS.get("assets/config.toml").unwrap();
}
The archive uses a simple binary format:
[Header]
[File Data Section - concatenated file contents]
Magic Number: 4 bytes (b"INFS")
File Count: 4 bytes (u32, little-endian)
For each file:
Path Length: 2 bytes (u16, little-endian)
Path: variable (UTF-8 string)
File Size: 8 bytes (u64, little-endian)
Data Offset: 8 bytes (u64, little-endian)