https://github.com/tilpner/includedir
Include a whole directory tree at compile time
https://github.com/tilpner/includedir
assets filesystem include rust
Last synced: about 1 month ago
JSON representation
Include a whole directory tree at compile time
- Host: GitHub
- URL: https://github.com/tilpner/includedir
- Owner: tilpner
- License: bsd-3-clause
- Created: 2016-02-16T18:05:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-27T11:50:13.000Z (almost 5 years ago)
- Last Synced: 2025-04-01T09:08:17.661Z (about 2 months ago)
- Topics: assets, filesystem, include, rust
- Language: Rust
- Size: 53.7 KB
- Stars: 81
- Watchers: 3
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
includedir
===========[](https://travis-ci.org/tilpner/includedir)
[](https://ci.appveyor.com/project/tilpner/includedir)
[](https://crates.io/crates/includedir)
[](https://docs.rs/includedir)
[](https://crates.io/crates/includedir)Include a directory in your Rust binary, e.g. static files for your web server or assets for your game.
## Features
* [x] Automatically compile data into binary
* [x] Use [rust-phf](https://github.com/sfackler/rust-phf) for efficient lookup
* [x] Wrapping API around the phf map, to abstract away additional features
* [x] Compression, with optional crate "flate2"
* [x] Reading from source files for debug builds## Example
**Cargo.toml**
```toml
[package]
name = "example"
version = "0.1.0"build = "build.rs"
include = ["data"][dependencies]
phf = "0.8.0"
includedir = "0.6.0"[build-dependencies]
includedir_codegen = "0.6.0"
```**build.rs**
```rust
extern crate includedir_codegen;use includedir_codegen::Compression;
fn main() {
includedir_codegen::start("FILES")
.dir("data", Compression::Gzip)
.build("data.rs")
.unwrap();
}
```**src/main.rs**
```rust
extern crate includedir;
extern crate phf;use std::env;
include!(concat!(env!("OUT_DIR"), "/data.rs"));
fn main() {
FILES.set_passthrough(env::var_os("PASSTHROUGH").is_some());println!("{:?}", FILES.get("data/foo"))
}
```