Expand description
Compile-time-embedded static assets — the runtime hook for the
embed-assets feature.
Disk-served public/ mounts continue to work via tower_http::ServeDir.
When an app wants to ship as a single executable, it derives a
rust_embed::RustEmbed struct on its public/ folder and registers a
fetcher here; server::mount_static then consults this registry before
falling back to disk.
Registration is global because the user’s RustEmbed type lives in their
crate, not in the framework, and we need a way to bridge across that
boundary without leaking generics through every config struct.
Structs§
- Embedded
Asset - A single embedded file’s payload + metadata. Mirrors what
rust_embed::Fileexposes, but kept framework-owned so the runtime API stays stable if we later swap the embedder.
Functions§
- guess_
mime - Resolve a file path’s MIME type via
mime_guess, defaulting toapplication/octet-streamwhen the extension is unknown. Provided as a convenience for fetcher implementations. - lookup
- Look up the fetcher for a mount prefix. Returns
Nonewhen the mount has no embedded backing and the caller should fall through to disk serving. - register
- Register an embedded-asset fetcher for the given URL prefix (e.g.
"/assets"). Call this from app bootstrap beforeserve()runs. Re-registering the same prefix replaces the previous fetcher — last writer wins.
Type Aliases§
- Embedded
Asset Fetcher - Function pointer signature that backs an embedded mount. Takes a path
relative to the mount root (
foo/bar.css, no leading slash) and returns the file if it exists in the embedded set.