Function bones_asset::prelude::asset_loader
source · pub fn asset_loader<L: AssetLoader, E: Into<AssetExtensions>>(
extensions: E,
loader: L,
) -> AssetKind
Expand description
Helper function to return type data for a custom asset loader.
§Example
This is meant to be used in a type_data
attribute when deriving HasSchema
.
#[derive(HasSchema, Default, Clone)]
#[type_data(asset_loader("png", PngLoader))]
#[repr(C)]
struct Image {
data: SVec<u8>,
width: u32,
height: u32,
}
struct PngLoader;
impl AssetLoader for PngLoader {
fn load(&self, ctx: AssetLoadCtx, data: &[u8]) -> BoxedFuture<anyhow::Result<SchemaBox>> {
Box::pin(async move {
todo!("Load PNG from data");
})
}
}