Skip to main content

Crate rosace_asset_codegen

Crate rosace_asset_codegen 

Source
Expand description

Build-time asset codegen (A6, layer 2). Scans an app’s assets/ dir and emits a typed assets module of const Asset handles, so Image::asset(assets::LOGO) is typo-proof and autocompletes — with the folder itself as the declaration (no hand-maintained manifest).

Apps call this from build.rs:

fn main() {
    rosace_asset_codegen::generate("assets");
}

and include the result once:

pub mod assets {
    include!(concat!(env!("OUT_DIR"), "/rosace_assets.rs"));
}

It re-runs only when the asset tree changes (cargo:rerun-if-changed), so it costs nothing on ordinary code edits, and the generated code is a flat tree of consts — dead simple, so it never slows the compiler down.

Functions§

generate
Scan assets_dir and write the typed assets module to $OUT_DIR/rosace_assets.rs. Call from build.rs. Uses the default handle type path rosace::asset::Asset; see generate_with to override it.
generate_with
Like generate but lets you name the Asset type path (for apps that use rosace_core directly rather than the rosace umbrella).