glace

Crates.ioglace
lib.rsglace
version0.1.0
sourcesrc
created_at2022-10-20 21:32:22.686405
updated_at2022-10-20 21:32:22.686405
descriptionA type-safe, user-friendly proc macro for embedding a file tree into your code.
homepagehttps://github.com/mistodon/glace
repositoryhttps://github.com/mistodon/glace
max_upload_size
id692982
size44,947
Vi (mistodon)

documentation

README

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.
Commit count: 27

cargo fmt