tower-serve-embedded-build 0.1.0

Build-time helper for tower-serve-embedded: walks an asset directory, content-hashes each file, and generates the embedded manifest and `asset!` macro. Use it from your build.rs.
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented0 out of 5 items with examples
  • Size
  • Source code size: 18.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 322.99 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vanhouc

tower-serve-embedded-build

Build-time helper for tower-serve-embedded.

Call it from your crate's build.rs. It walks an asset directory, content-hashes every file with BLAKE3, detects MIME types, and generates a Rust file (in OUT_DIR) containing the embedded manifest (ASSETS) and a compile-time asset! macro. There are no proc macros — the generated code is plain data plus a tiny macro_rules!, so IDE support stays sharp.

# Cargo.toml
[build-dependencies]
tower-serve-embedded-build = "0.1"
// build.rs
fn main() {
    tower_serve_embedded_build::Builder::new("assets") // dir relative to your crate root
        // .ignore_dir("lib")                           // skip a subdir, e.g. vendored deps
        // .hash_length(16)                             // hash chars in filenames/ETags
        .emit()
        .unwrap();
}

Then pull the generated code into your crate with tower_serve_embedded::embed!(), which brings the ASSETS static and the asset! macro into scope.

See the tower-serve-embedded crate for the full story, the runtime tower::Service, and runnable axum/actix/warp examples.

License

MIT OR Apache-2.0.