use assets_manager::{AssetCache, AssetGuard, Compound};
use crate::Settings;
#[cfg(not(feature = "embed-assets"))]
pub struct Assets(AssetCache<assets_manager::source::FileSystem>);
#[cfg(feature = "embed-assets")]
pub struct Assets(AssetCache<assets_manager::source::Embedded<'static>>);
impl Assets {
pub fn load() -> Self {
#[cfg(not(feature = "embed-assets"))]
let source = assets_manager::source::FileSystem::new("assets").unwrap();
#[cfg(feature = "embed-assets")]
let source =
assets_manager::source::Embedded::from(assets_manager::source::embed!("assets"));
let asset_cache = AssetCache::with_source(source);
Self(asset_cache)
}
pub fn settings(&self) -> AssetGuard<Settings> {
self.0.load_expect("settings").read()
}
pub fn asset<T>(&self, path: &str) -> AssetGuard<T>
where
T: Compound,
{
self.0.load_expect(path).read()
}
pub fn enable_hot_reloading(&'static self) {
self.0.enhance_hot_reloading();
}
}