https://github.com/tauri-apps/tauri-includedir
https://github.com/tauri-apps/tauri-includedir
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tauri-apps/tauri-includedir
- Owner: tauri-apps
- License: bsd-3-clause
- Archived: true
- Created: 2019-12-16T02:17:40.000Z (over 5 years ago)
- Default Branch: dev
- Last Pushed: 2021-06-06T00:36:08.000Z (about 4 years ago)
- Last Synced: 2024-04-22T09:56:07.235Z (about 1 year ago)
- Language: Rust
- Size: 93.8 KB
- Stars: 5
- Watchers: 4
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tauri_includedir
===========## Deprecation notice
This crate was deprecated. It is now part of the `tauri-codegen` crate.
# tauri-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"
tauri_includedir = "0.5.0"[build-dependencies]
tauri_includedir_codegen = "0.5.0"
```**build.rs**
```rust
extern crate tauri_includedir_codegen;use tauri_includedir_codegen::Compression;
fn main() {
tauri_includedir_codegen::start("FILES")
.dir("data", Compression::Gzip)
.build("data.rs")
.unwrap();
}
```**src/main.rs**
```rust
extern crate tauri_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"))
}
```