Skip to content
/ glace Public

A type-safe, user-friendly proc macro for embedding a file tree into your code.

Notifications You must be signed in to change notification settings

mistodon/glace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A type-safe, user-friendly proc macro for embedding a file tree into your code.

Resources

Stars

Watchers

Forks

Packages

No packages published