#assets #template #web-apps #information #hash #offers #reinda

reinda-core

Internal crate for reinda. Do not use this crate directly! See the main crate for more information.

3 releases

0.0.3 Apr 17, 2023
0.0.2 Jan 27, 2021
0.0.1 Jan 22, 2021

#246 in Caching

Download history 40/week @ 2024-01-08 19/week @ 2024-01-15 13/week @ 2024-02-12 31/week @ 2024-02-19 79/week @ 2024-02-26 24/week @ 2024-03-04 18/week @ 2024-03-11

153 downloads per month
Used in 2 crates

MIT/Apache

14KB
269 lines

reinda: easily embed and manage assets

CI status of master Crates.io Version docs.rs

This library helps you manage your assets (external files) and is mostly intended to be used in web applications. Assets can be embedded into the binary file to obtain an easy to deploy standalone executable. This crate also offers a template engine and the ability to automatically include a hash of an asset's content into its filename (useful for 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, Assets, Config, Setup};

const ASSETS: Setup = assets! {
    #![base_path = "assets"]

    "index.html": { template },
    "bundle.js": { hash },
};


let assets = Assets::new(ASSETS, Config::default()).await?;

// Retrieve specific asset. You can now send this data via HTTP or use it however you like.
let bytes /* : Option<bytes::Bytes> */ = assets.get("index.html")?;

See the documentation for more information.

Features

  • Embed files at compile time (in prod mode) or load them at runtime (in dev mode)
  • Allow for dynamic files which will always be loaded at runtime
  • Include content hash in filename (has to be enabled per asset)
  • Template system
    • Include other assets
    • Refer to other assets by path
    • Use runtime variables
  • Compress embedded files to shrink the resulting binary
  • Cargo feature to embed everything in debug mode
  • Template syntax checked at compile time (in prod mode)
  • Well tested

Status of this project

This project is very young. I developed it specifically for a web application I work on where rust-embed did not offer enough features. You should absolutely not use this in production yet, but you sure can try it out.

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

~0.6–1.3MB
~26K SLoC