#include #tree #directory #build #static

tauri_includedir

Include a whole directory tree at compile time! - Runtime part

2 unstable releases

0.6.0 Jun 25, 2020
0.5.0 Dec 16, 2019

#148 in Filesystem

Download history 618/week @ 2020-05-18 936/week @ 2020-05-25 771/week @ 2020-06-01 1449/week @ 2020-06-08 824/week @ 2020-06-15 1257/week @ 2020-06-22 583/week @ 2020-06-29 1584/week @ 2020-07-06 1069/week @ 2020-07-13 784/week @ 2020-07-20 817/week @ 2020-07-27 683/week @ 2020-08-03 620/week @ 2020-08-10 1121/week @ 2020-08-17 942/week @ 2020-08-24 865/week @ 2020-08-31

3,238 downloads per month
Used in 2 crates (via tauri)

BSD-3-Clause

4KB
72 lines

tauri_includedir

Include a directory in your Rust binary, e.g. static files for your web server or assets for your game.

Features

  • Automatically compile data into binary
  • Use rust-phf for efficient lookup
  • Wrapping API around the phf map, to abstract away additional features
  • Compression, with optional crate "flate2"
  • Reading from source files for debug builds

Example

Cargo.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

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

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"))
}

Dependencies

~385KB