Skip to main content

Crate tower_serve_embedded_build

Crate tower_serve_embedded_build 

Source
Expand description

Build-time helper for tower-serve-embedded.

Call this from your crate’s build.rs. It walks an asset directory, content-hashes every file with BLAKE3, and writes a generated Rust file to OUT_DIR containing the embedded manifest (ASSETS) and a compile-time asset! macro. Pull that into your crate with tower_serve_embedded::embed!().

// build.rs
fn main() {
    tower_serve_embedded_build::Builder::new("assets").emit().unwrap();
}

Asset paths are expressed relative to the crate root, so the embedded URL mirrors the file’s location in your project. Ordinary files are served at a cache-busted URL (/assets/css/style.<hash>.css). Files under Builder::immutable_dir are treated as already versioned and served only at their plain URL (/assets/lib/htmx-1.9.10.min.js). Hidden files and directories (names starting with .) and symlinks are ignored.

Structs§

Builder
Configures and runs asset embedding from a build.rs.