pocket-resources 0.2.0

Include resources in your applications.
docs.rs failed to build pocket-resources-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: pocket-resources-0.3.2

Pocket-resources

Usage

See the demo crate.

Tweak your Cargo.toml to use a build script:

[package]
# ...
build = "build.rs"

[build-dependencies]
pocket-resources = "*"

Create a build.rs file:

extern crate pocket_resources;

fn main() {
    pocket_resources::package(&["resources"]).unwrap();
}

Include the resources where you want:

include!(concat!(env!("OUT_DIR"), "/pocket-resources.rs"));

This creates a public enum named Resource. If you want to name it something else, or if you want it private, you should use a module.

You can then load the resource directly from the enum:

let data: &[u8] = Resource::PathToImagePng.load();

Or load it at runtime:

let data: &[u8] = Resource::from_name("path/to/image.png").unwrap().load();