1 unstable release

0.1.0 Oct 20, 2022

#43 in #file-tree


Used in glace

CC0 license

55KB
1K SLoC

glacé

(Like the cherries.)

A proc macro for embedding an entire directory tree into your Rust code in a type-safe, human-friendly, flexible way.

CI Docs.rs Crates.io codecov

At its simplest, it provides you with an enum variant matching every file in the tree, so you know at compile-time that the paths to your assets exist. At its most powerful, it can load all of those files into const memory, generate serde structs to represent them, provide methods for loading and deserializing (and transparently cacheing) them.

The ideal future of this crate is to fully abstract away the notion of files and allow you to write code as though all of your assets are hard-coded (without, of course, having to hard-code them). We're not there yet, but what's implemented already is useful in its own right.

Usage

See docs.rs/glace (and in particular the docs_only_example_assets module) to get some idea of what glace generates for you.

See also the testcrate crate in this repo for some examples of how to use the results.

Some gotchas

  1. The path taken by glace! is relative to the workspace, if a workspace is being used. I don't know how to change that.

Dependencies

~9–20MB
~273K SLoC