gitdataai/libs/frontend/src/lib.rs

16 lines
646 B
Rust

//! Embedded frontend static assets, built via pnpm and embedded at compile time.
include!(concat!(env!("OUT_DIR"), "/frontend.rs"));
/// Returns the embedded frontend static asset for the given path, or `None` if not found.
pub fn get_frontend_asset(path: &str) -> Option<&'static [u8]> {
FRONTEND.iter().find(|(k, _, _)| *k == path).map(|(_, v, _)| *v)
}
/// Returns the embedded frontend static asset and its ETag for the given path.
pub fn get_frontend_asset_with_etag(path: &str) -> Option<(&'static [u8], &'static str)> {
FRONTEND.iter()
.find(|(k, _, _)| *k == path)
.map(|(_, v, etag)| (v as &_, etag as &_))
}