Function bones_framework::asset::prelude::asset_loader

pub fn asset_loader<L, E>(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]) -> futures::future::Boxed<anyhow::Result<SchemaBox>> {
        Box::pin(async move {
            todo!("Load PNG from data");
        })
    }
}