Easily embed a directory of files into a rust program, with xz and gzip compression support. Lazy unpack and cache files via random access, or inflate them all up front.
In your_crate/embed/hello.txt
:
Hello World!
In your_crate/build.rs
:
fn main() {
packdir::pack("./embed", "embed", packdir::Xz::best()).expect("embed dir");
}
In your_crate/src/main.rs
:
fn main() {
let mut embed = packdir::unpack!("embed");
println!("entires: {:?}", embed.entries()); // entries: ["hello.txt"]
let content = embed.get("hello.txt");
println!("content = {content:?}"); // content = "Hello World!"
}