Function gemgui::respack::pack

source ·
pub fn pack<PathStr>(directory: PathStr, try_minify: bool)where
    PathStr: AsRef<Path>,
Expand description

Pack a folder as a resources Assumed to be called at build.rs, i.e. build time only Generates a source file “generated.rs” that can be included in the application sources and be loaded as a filemap for a dynamic access.

Add in Cargo.toml

[build-dependencies]
gemgui = "...""

…and apply build.rs ‘gui’ refers to directory the resources all locate. All files in the directory are read in resources.

fn main() {
    println!("cargo:rerun-if-changed=gui");
    gemgui::respack::pack("gui", false);
}

Then resources can be read in sources as

include!(concat!(env!("OUT_DIR"), "/generated.rs"));

…and read in for the Ui as

let fm = gemgui::filemap_from(RESOURCES);
let mut ui = Ui::new(fm, "hello.html", 12345)?;

Arguments

´directory´ - Directory to read in resources. Does not read sub directories.

´try_minify´ - May to apply minify / compress.