Merge pull request #4 from remexre/master
Doc fixes, no longer uploads kermit to crates.io...
|2 weeks ago|
|packer_derive||2 weeks ago|
|src||2 weeks ago|
|static||5 months ago|
|tests||2 weeks ago|
|.gitignore||5 months ago|
|.travis.yml||2 weeks ago|
|Cargo.toml||2 weeks ago|
|LICENSE||2 weeks ago|
|README.md||2 weeks ago|
NOTE This project is based on the original rust-embed. I made enough modifications to it that I decided to just publish it in a separate repository.
NOTE This project requires a Rust 2018 (Rust 1.31+) compiler.
packer is a library that helps you pack static files into binaries using macro magic. Here’s how it’s done:
Include the crate in your
[dependencies] packer = "0.3"
Packer from your structs. You need to provide a
folder attribute to indicate the folder from which it should be pulling. Paths are relative to the crate root.
use packer::Packer; #[derive(Packer)] #[folder = "static"] struct Assets;
You can now access any file using the
use packer::Packer; let data: Option<&'static [u8]> = Assets::get("kermit.jpg");
You may also choose to list all the files that have been stored.
use packer::Packer; let files /*: impl Iterator<Item = &'static str>*/ = Assets::list();
(See the documentation for the Packer trait for the full listing of methods.)
When you build in dev mode, it will fetch off your filesystem as usual, but when you build with
--release, it will pack the assets into your binary!
Author: Michael Zhang, Nathan Ringo