#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct Asset {
pub path: &'static str,
pub contents: &'static str,
}
include!(concat!(env!("OUT_DIR"), "/assets.rs"));
pub fn css_assets() -> &'static [Asset] {
CSS_ASSETS
}
pub fn js_assets() -> &'static [Asset] {
JS_ASSETS
}
pub fn foundry_assets() -> &'static [Asset] {
FOUNDRY_ASSETS
}
pub fn all_assets() -> impl Iterator<Item = &'static Asset> {
CSS_ASSETS.iter().chain(JS_ASSETS).chain(FOUNDRY_ASSETS)
}
pub fn asset(path: &str) -> Option<&'static Asset> {
all_assets().find(|asset| asset.path == path)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn exposes_core_css_asset() {
let index = asset("css/index.css").expect("index css should be embedded");
assert!(index.contents.contains("tokens.css"));
}
#[test]
fn exposes_foundry_component_asset() {
let button = asset("foundry/Button.ax").expect("button component should be embedded");
assert!(button.contents.contains("page Button"));
}
}