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

Overview

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.

Comments
  • Use `twoway` to do fast subslice search

    Use `twoway` to do fast subslice search

    This has quite a notable performance impact. In a 3MB bundle.js it took roughly 400ms to parse the file before this commit. Now it's at most a few tens of ms.

    opened by LukasKalbertodt 0
  • Compress embedded files

    Compress embedded files

    This should shrink the binary file, probably considerably. Note that this issue is not about transport-level compression. We miiight want to add something for that later, too, but not now.

    opened by LukasKalbertodt 0
  • Community Feedback

    Community Feedback

    Do you have any opinions, complaints, suggestions, ideas, ... about this library? Let me know! This issue is less formal and more relaxed than "normal issues", so feel free to just dump your thoughts here.

    opened by LukasKalbertodt 0
  • Add tests

    Add tests

    This crate should have tons of automated tests. Now that the API is somewhat stable, I can start adding them. An incomplete list of things that need testing:

    • [x] template: false with template syntax in it
    • [x] serve: false
    • [ ] dynamic: true
    • [x] Assets in subdirectories of the base path
    • [ ] Cyclic include with 2 files
    • [ ] Missing variables
    • [ ] path overrides
    • [ ] Different runtime base path
    opened by LukasKalbertodt 0
  • Fix paths on Windows

    Fix paths on Windows

    I didn't pay any attention to cross platform paths when writing this lib. I even, dare I say it, at some point joined two paths with format!. So yeah, that needs to be fixed.

    opened by LukasKalbertodt 0
  • Check for potential path traversal attack vectors

    Check for potential path traversal attack vectors

    I thought a bit about this problem, and right now, I don't think reinda itself can be responsible for letting a PTA through. The get method checks either self.setup.assets or self.assets. In both cases, there are only entries that were manually listed in assets!.

    However: I should check this more thoroughly and reinda should help to prevent PTA vulnerabilities in user code. For example, one could disallow .. in in the asset paths. Or we can add more docs to relevant base_paths to tell users to beware of PTAs.

    opened by LukasKalbertodt 0
Releases(v0.2.0)
Owner
Lukas Kalbertodt
I like teaching and coding.
Lukas Kalbertodt
Hiccup html templating in rust

Hiccup A Clojure's Hiccup inspired macro. At the moment support for inline code execution is not guaranteed. The main objective of this lib is to prev

Julia Naomi 13 May 28, 2022
Automatic HTTPS certificates for Tide, via Let's Encrypt and ACME tls-alpn-01 challenges

tide-acme helps you serve HTTPS with Rust and Tide using automatic certificates, via Let's Encrypt and ACME tls-alpn-01 challenges. Documentation To u

http-rs 158 Oct 9, 2022
Quickly create boilerplate projects and templates.

boyl boyl is a command-line tool written in Rust to manage template folders. boyl can copy existing folders (with support for glob-like ignore pattern

Miguel M. 13 Feb 16, 2022
finch - a super fast and efficient template rendering engine for node.js

finch A super fast and efficient template rendering engine for node.js, inspired by Handlebars. Usage Finch is very simple to use: Register a template

null 1 Nov 2, 2021
A template for creating services in Rust using Axum and Prisma.

A template for creating services in Rust using Axum and Prisma. This uses the super cool Prisma Rust Client.

Aaron Leopold 6 Oct 19, 2022
📦 Distribute Roblox games as standalone executables -- No existing client necessary. 🚧

?? Packer Distribute Roblox games as standalone executables. ?? Packer is still being worked on. Among many other things, Windows is not currently sup

Brooke Rhodes 16 Dec 20, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Static Web Server - a very small and fast production-ready web server suitable to serve static web files or assets

Static Web Server (or SWS abbreviated) is a very small and fast production-ready web server suitable to serve static web files or assets.

Jose Quintana 496 Jan 2, 2023
zigfi is an open-source stocks, commodities and cryptocurrencies price monitoring CLI app, written fully in Rust, where you can organize assets you're watching easily into watchlists for easy access on your terminal.

zigfi zigfi is an open-source stocks, commodities and cryptocurrencies price monitoring CLI app, written fully in Rust, where you can organize assets

Aldrin Zigmund Cortez Velasco 18 Oct 24, 2022
A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. :zap::crab:

binserve ⚡ ?? A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. ?? UPDATE: N

Mufeed VH 722 Dec 27, 2022
📦 Crate Protocol allows anyone to create, manage, and trade a tokenized basket of assets, which we refer to as a Crate.

?? Crate Protocol Crate Protocol allows anyone to create, manage, and trade a tokenized basket of assets, which we refer to as a Crate. A Crate is alw

Crate Protocol 63 Oct 31, 2022
A CLI companion tool for paste.misterio.me, allowing you to easily upload and manage your pastes

This is a CLI companion tool for paste.misterio.me, allowing you to easily upload and manage your pastes, as well as download any pastes you want.

Gabriel Fontes 1 Jan 26, 2022
Hotham is a framework for quickly and easily creating amazing standalone VR experiences.

?? Under construction! Please mind the mess! ?? Introduction G'day, and welcome to Hotham! ?? Hotham is an attempt to create a lightweight, high perfo

Let Eyes Equals Two 296 Dec 29, 2022
SubZero - a standalone web server that turns your database directly into a REST/GraphQL api

What is this? This is a demo repository for the new subzero codebase implemented in Rust. subZero is a standalone web server that turns your database

subZero 82 Jan 1, 2023
Image proxy and embed generator.

January Description Image proxy and metadata scraper. Features: Can scrape metadata from websites, e.g. OpenGraph Can scrape embeds from websites, e.g

Revolt 26 Dec 26, 2022
A setuptools/wheel/cffi extension to embed a binary data in wheels

Milksnake Milksnake is an extension for setuptools that allows you to distribute dynamic linked libraries in Python wheels in the most portable way im

Sentry 752 Dec 30, 2022
PyOxidizer is a utility for producing binaries that embed Python

PyOxidizer is a utility for producing binaries that embed Python. The over-arching goal of PyOxidizer is to make complex packaging and distribution problems simple so application maintainers can focus on building applications instead of toiling with build systems and packaging tools.

Gregory Szorc 4.5k Jan 4, 2023
Safe API to embed an ECMAScript engine.

Kopi Kopi is a small abstraction to easily and safely embed an ECMAScript runtime inside a Rust based application. It uses the V8 execution engine to

Nils Hasenbanck 3 Dec 20, 2022
Build, bundle & ship your Rust WASM application to the web.

Trunk Build, bundle & ship your Rust WASM application to the web. ”Pack your things, we’re going on an adventure!” ~ Ferris Trunk is a WASM web applic

Anthony Dodd 2.2k Jan 7, 2023
Build smaller, faster, and more secure desktop applications with a web frontend.

TAURI Tauri Apps footprint: minuscule performance: ludicrous flexibility: gymnastic security: hardened Current Releases Component Descrip

Tauri 56.3k Jan 3, 2023