| Crates.io | embed-resources |
| lib.rs | embed-resources |
| version | 0.1.0-alpha6 |
| created_at | 2025-01-26 06:24:58.128643+00 |
| updated_at | 2025-02-23 04:00:51.97017+00 |
| description | A simple Rust crate to embed resources (files, URLs, data) as byte arrays. |
| homepage | |
| repository | https://github.com/jzombie/rust-embed-bytes |
| max_upload_size | |
| id | 1531104 |
| size | 47,422 |
This is a prototype; the documentation may not be correct, and the API is subject to change.
embed-resources is a Rust crate built on top of embed-bytes that extends its functionality to handle multiple resource types: local files, URLs, and in-memory data. It also supports optional Gzipped compression for reduced storage size.
Unlike embed-bytes, which directly embeds assets, embed-resources simplifies managing mixed resources by organizing them in a virtual "container." Resources are automatically converted into .bin files, and a Rust source file is generated to embed them using include_bytes!.
In build.rs:
use embed_resources::{Resource, ResourceContainer};
use std::path::Path;
fn main() -> std::io::Result<()> {
let mut container = ResourceContainer::new(Path::new("embed"));
container.add_resource("local_file", Resource::File("assets/file.txt".to_string()), true);
container.add_resource("remote_data", Resource::Url("https://example.com/data.bin".to_string()), true);
container.add_resource("in_memory_data", Resource::Data(bytes::Bytes::from("Hello, world!")), true);
container.embed_all()?;
Ok(())
}
This creates .bin files and a Rust source file in the embed/ directory, ready to use with include_bytes!.
MIT License (c) 2025 Jeremy Harris.