use keket::{
database::AssetDatabase,
fetch::{fallback::FallbackAssetFetch, file::FileAssetFetch},
protocol::text::TextAssetProtocol,
};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let mut database = AssetDatabase::default()
.with_protocol(TextAssetProtocol)
.with_fetch(
FallbackAssetFetch::new(FileAssetFetch::default().with_root("resources"))
.path("text://this-fails-to-load.txt")
.path("text://lorem.txt"),
);
let lorem = database.ensure("text://lorem.txt")?;
let non_existent = database.ensure("text://non-existent.txt")?;
if lorem.access::<&String>(&database) == non_existent.access::<&String>(&database) {
println!("Non existent asset loaded from fallback!");
}
Ok(())
}