| Crates.io | keket-redb |
| lib.rs | keket-redb |
| version | 0.15.6 |
| created_at | 2025-01-12 02:37:33.332673+00 |
| updated_at | 2025-08-23 00:26:44.608678+00 |
| description | REDB asset fetch for Keket toolkit |
| homepage | https://github.com/PsichiX/keket |
| repository | https://github.com/PsichiX/keket |
| max_upload_size | |
| id | 1512903 |
| size | 38,392 |
Database-like Asset management on top of ECS storage.
This crate provides a robust framework for managing assets in Rust, from loading and fetching assets from various sources (HTTP, local file system, databases, etc.) to advanced features like asset hot-reloading, deferred and async loading, and integration with game engines or other large projects. It leverages dynamic component-based bundles to easily manage and interact with assets on demand.
DynamicBundle container.ContainerPartialFetch trait.use keket::{
database::{path::AssetPath, AssetDatabase},
fetch::file::FileAssetFetch,
protocol::{bundle::BundleAssetProtocol, bytes::BytesAssetProtocol, text::TextAssetProtocol},
};
use serde_json::Value;
use std::{error::Error, fs::Metadata, path::PathBuf};
fn main() -> Result<(), Box<dyn Error>> {
let mut database = AssetDatabase::default()
.with_protocol(TextAssetProtocol)
.with_protocol(BytesAssetProtocol)
.with_protocol(BundleAssetProtocol::new("json", |bytes: Vec<u8>| {
Ok((serde_json::from_slice::<Value>(&bytes)?,).into())
}))
.with_fetch(FileAssetFetch::default().with_root("resources"));
let lorem = database.ensure("text://lorem.txt")?;
println!("Lorem Ipsum: {}", lorem.access::<&String>(&database));
let person = database.ensure("json://person.json")?;
println!("Person: {:#?}", person.access::<&Value>(&database));
let trash = database.ensure("bytes://trash.bin")?;
println!("Bytes: {:?}", trash.access::<&Vec<u8>>(&database));
for (asset_path, file_path, metadata) in database
.storage
.query::<true, (&AssetPath, &PathBuf, &Metadata)>()
{
println!(
"Asset: `{}` at location: {:?} has metadata: {:#?}",
asset_path, file_path, metadata
);
}
Ok(())
}
More examples:
Keket asset management design is built around modularity to allow users to change parts to build their asset pipeline tailored to their needs.
Key concepts:
AssetDatabase - central place where assets live. ECS storage allows for ergonomics of access and processing of huge amount of data at once in database-like manner.AssetHandle - wrapper around asset entity that allows easy direct operations and access to resolved asset. Asset databaseAssetPath - specialized path that describes an asset identifier (<protocol>://<path/to/asset.extension>?<meta-information>).
Examples:
image://grass.pngmesh://teapot.gltf?lod=2AssetRef - wrapper around asset path and cached asset handle. Useful for serialization. Allows to resolve asset once and reuse cached handle later.SmartAssetRef - Reference-counted version of AssetRef that allows automatic unloading assets that aren't referenced anywhere.AssetFetch - an engine telling where from asset bytes are loaded. Basic one is FileAssetFetch.AssetStore - an engine telling where to asset bytes are stored. Basic one is FileAssetStore.AssetProtocol - an engine telling how fetched asset bytes are decoded into asset components, selected based on asset path protocol part. For example TextAssetProtocol or BytesAssetProtocol.Whether you're building games, web apps, or anything else that requires managing and fetching assets, this crate has you covered with ease and flexibility. Enjoy on-the-fly reloading, asynchronous fetching, and a simple, intuitive API designed with efficiency in mind.