Skip to main content

fs_embed

Macro fs_embed 

Source
macro_rules! fs_embed {
    ($($tokens:tt)*) => { ... };
}
Expand description

A rust_embed asset source that embeds files in release builds. Dev builds read from the checkout at runtime unless the debug-embed feature is enabled, in which case they embed the files too.

It expands to one of these arms:

  • Release (not(debug_assertions)): #[derive(RustEmbed)] embedding crate_relative at build time, with the given include/exclude globs.
  • Dev with debug-embed: the same compile-time embedding as release.
  • Dev without debug-embed: a runtime filesystem source rooted at root_relative; edits appear on the next launch without a rebuild.

Two paths are required because the arms resolve from different bases: the derive reads crate_relative relative to the crate’s Cargo.toml, while the runtime dev arm resolves root_relative relative to the repository root via dev_repo_root. Baking the build-time path into that arm would point at the wrong checkout from another worktree and is rejected by corgi, whose sandbox requires checkout-independent output.

ⓘ
util::fs_embed! {
    pub struct Assets,
    crate_relative = "../../assets",
    root_relative = "assets",
    include = ["fonts/**/*", "themes/**/*", "*.md"],
    exclude = ["themes/src/*", "*.DS_Store"],
}