Crate of the Week

Self-nominating embed_it.

A crate that helps you to embed assets into your binary and generates structs / trait implementations for each file or directory

Unlike include_dir and rust-embed it generates strongly-typed structures to avoid problems with hardcoded paths and vanished files.

In addition, it allows you to choose what exactly should be compiled, for example, if you only need file metadata or only a hash of a certain type, then you can embed them only

The simplest example:

#[derive(Embed)]
#[embed(path = "$CARGO_MANIFEST_DIR/assets")]
pub struct Assets;

assert_eq!(
    Assets
        .dir_1()
        .subdir()
        .readme()
        .content(), 
    b"My content"
);

4 Likes