9 releases

Uses old Rust 2015

0.3.2 Jan 2, 2016
0.3.1 Dec 6, 2015
0.2.2 Aug 5, 2015
0.2.1 May 15, 2015
0.1.0 Mar 27, 2015

#686 in Build Utils

Download history 2274/week @ 2024-08-26 2412/week @ 2024-09-02 2451/week @ 2024-09-09 2597/week @ 2024-09-16 2982/week @ 2024-09-23 2831/week @ 2024-09-30 2894/week @ 2024-10-07 3814/week @ 2024-10-14 3557/week @ 2024-10-21 4195/week @ 2024-10-28 3181/week @ 2024-11-04 3310/week @ 2024-11-11 3218/week @ 2024-11-18 3269/week @ 2024-11-25 3268/week @ 2024-12-02 2557/week @ 2024-12-09

12,639 downloads per month
Used in 24 crates (2 directly)

MIT license

9KB
150 lines

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();

No runtime deps