/reinda

Easily embed and manage assets for your web application to build standalone-executables. Offers filename hashing, templating and more.

Primary LanguageRustApache License 2.0Apache-2.0

reinda: easily embed and manage assets

CI status of main Crates.io Version docs.rs

This library helps your web applications manage your assets (external files). Assets can be compressed and embedded into the binary file to obtain an easy to deploy standalone executable. In debug mode, assets are loaded dynamically to avoid having to recompile the backend. A hash can be automatically included in an asset's filename to enable good caching on the web. In release mode, this crate prepares everything up-front such that the actually serving the file via HTTP can be as fast as possible.

You might know the crate rust-embed: reinda does basically the same, but for the most part has more features and is more flexible (in my opinion).

Tiny example:

use reinda::{Assets, Embeds, embed};

// Embed some assets
const EMBEDS: Embeds = embed! {
    base_path: "../assets",
    files: ["index.html", "bundle.*.js"],
};

// Configure assets
let mut builder = Assets::build();
builder.add_embedded("index.html", &EMBEDS["index.html"]);
builder.add_embedded("static/", &EMBEDS["bundle.*.js"]);
let assets = builder.build().await?;

// Retrieve asset for serving. The `.await?` is only there for the "dev" mode
// when the file is dynamically loaded. In release mode, the final `Bytes`
// are already stored inside `assets`.
let bytes = assets.get("index.html").unwrap().content().await?;

See the documentation for more information.

Status of this project

While this crate is not used by many projects yet, we use it in production for a couple of years already. If you have any thoughts about this project, please let me know in this community feedback issue!



License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.