assets
Embedded static assets served via rust-embed.
struct StaticAssets
struct StaticAssets;The .css and .js files under templates/, embedded in the binary at build time.
Implements RustEmbed.
StaticAssets::matcher
fn matcher() -> PathMatcher| Parameter | Type | Description |
|---|---|---|
| returns | PathMatcher |
StaticAssets::get
pub fn get(file_path: &str) -> Option<EmbeddedFile>Get an embedded file and its metadata.
| Parameter | Type | Description |
|---|---|---|
file_path |
&str | |
| returns | Option<EmbeddedFile> |
StaticAssets::iter
pub fn iter() -> impl Iterator<Item = Cow<'static, str>> + 'staticIterates over the file paths in the folder.
| Parameter | Type | Description |
|---|---|---|
| returns | impl Iterator<Item = Cow<'static, str>> + 'static |
fn serve
pub async fn serve(Path(path): Path<String>) -> ResponseServe an embedded static asset by path.
| Parameter | Type | Description |
|---|---|---|
Path(path) |
Path<String> | the asset’s path under templates/, from the /static/{*path} route |
| returns | Response | The asset’s bytes with a Content-Type from its extension, or an empty 404 response when no embedded asset has that path. |
fn mime_for
fn mime_for(path: &str) -> &'static strInfer a MIME type from the file extension.
| Parameter | Type | Description |
|---|---|---|
path |
&str | the asset’s path |
| returns | &'static str | The UTF-8 CSS or JavaScript type for .css and .js, and application/octet-stream for any other extension. |