#web-apps #assets #web #embed #standalone #http

reinda

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

4 releases (2 breaking)

new 0.3.0 May 15, 2024
0.2.1 Apr 17, 2023
0.2.0 Jan 27, 2021
0.1.0 Jan 22, 2021

#355 in Caching

Download history 1/week @ 2024-01-17 3/week @ 2024-02-07 8/week @ 2024-02-14 51/week @ 2024-02-21 39/week @ 2024-02-28 15/week @ 2024-03-06 10/week @ 2024-03-13 6/week @ 2024-03-27 21/week @ 2024-04-03

243 downloads per month

MIT/Apache

63KB
1K SLoC

Contains (WOFF font, 1KB) examples/assets/fonts/latin-i700.woff2, (WOFF font, 1KB) examples/assets/fonts/latin-400.woff2, (WOFF font, 1KB) examples/assets/fonts/latin-700.woff2, (WOFF font, 1KB) examples/assets/fonts/latin-i400.woff2

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.

Dependencies

~4–7MB
~158K SLoC