Skip to main content

Crate ferro_bundle

Crate ferro_bundle 

Source
Expand description

In-memory immutable byte blobs with content-hashed URLs and one-year immutable caching.

See the crate README for the bundle-vs-filesystem split: ferro-bundle handles compile-time-embedded immutable assets; the framework’s filesystem static-file handler at ferro_rs::static_files handles mutable on-disk tenant assets.

§Usage

Register bundles at boot, then dispatch via Bundle::serve in a handler mounted on /bundles/{filename} and on each registered alias path.

use ferro_bundle::Bundle;

// Boot-time registration. Builder order matters: content_type BEFORE with_alias.
Bundle::new("embed-v1", include_bytes!("../assets/embed-v1.js"))
    .content_type("application/javascript")
    .with_alias("/embed/v1.js");

async fn handler(req: ferro_rs::Request) -> ferro_rs::HttpResponse {
    Bundle::serve(req)
}

§Builder order

Boot-time builder chain: Bundle::new(name, bytes).content_type(ct).with_alias(path). Call .content_type(...) before .with_alias(...).content_type re-keys the bundle’s URL (the extension is appended), and .with_alias captures the current hashed URL at the time it is called.

Structs§

Bundle
In-memory immutable byte blob registered at boot.

Enums§

Error
Single error type for the ferro-bundle crate.

Type Aliases§

Result
Convenience alias.