pub trait AssetStorage {
// Required methods
fn update_asset(
&self,
loader_info: &dyn LoaderInfoProvider,
asset_type_id: &AssetTypeId,
data: Vec<u8>,
load_handle: LoadHandle,
load_op: AssetLoadOp,
version: u32,
) -> Result<(), Box<dyn Error + Send + 'static>>;
fn commit_asset_version(
&self,
asset_type: &AssetTypeId,
load_handle: LoadHandle,
version: u32,
);
fn free(
&self,
asset_type_id: &AssetTypeId,
load_handle: LoadHandle,
version: u32,
);
}Expand description
Storage for all assets of all asset types.
Consumers are expected to provide the implementation for this, as this is the bridge between
Loader and the application.
Required Methods§
Sourcefn update_asset(
&self,
loader_info: &dyn LoaderInfoProvider,
asset_type_id: &AssetTypeId,
data: Vec<u8>,
load_handle: LoadHandle,
load_op: AssetLoadOp,
version: u32,
) -> Result<(), Box<dyn Error + Send + 'static>>
fn update_asset( &self, loader_info: &dyn LoaderInfoProvider, asset_type_id: &AssetTypeId, data: Vec<u8>, load_handle: LoadHandle, load_op: AssetLoadOp, version: u32, ) -> Result<(), Box<dyn Error + Send + 'static>>
Updates the backing data of an asset.
An example usage of this is when a texture such as “player.png” changes while the application is running. The asset ID is the same, but the underlying pixel data can differ.
§Parameters
loader: Loader implementation calling this function.asset_type_id: UUID of the asset type.data: The updated asset byte data.load_handle: ID allocated byLoaderto track loading of a particular asset.load_op: Allows the loading implementation to signal when loading is done / errors.version: Runtime load version of this asset, increments each time the asset is updated.