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_dirand write the typedassetsmodule to$OUT_DIR/rosace_assets.rs. Call frombuild.rs. Uses the default handle type pathrosace::asset::Asset; seegenerate_withto override it. - generate_
with - Like
generatebut lets you name theAssettype path (for apps that userosace_coredirectly rather than therosaceumbrella).