pub trait AssetDataLoader {
// Required method
fn asset_from_bytes(
&self,
bytes: &[u8],
context: Option<Arc<dyn AssetManagerContext>>,
) -> Result<Box<dyn AssetData>, AssetLoadError>;
}Expand description
Trait for loading asset data from raw byte data.
Asset data loaders are responsible for converting raw bytes (typically read from files) into typed asset data that can be used by the application.
Required Methods§
Sourcefn asset_from_bytes(
&self,
bytes: &[u8],
context: Option<Arc<dyn AssetManagerContext>>,
) -> Result<Box<dyn AssetData>, AssetLoadError>
fn asset_from_bytes( &self, bytes: &[u8], context: Option<Arc<dyn AssetManagerContext>>, ) -> Result<Box<dyn AssetData>, AssetLoadError>
Converts raw bytes into asset data.
This method is called by the asset manager when raw asset data needs to be deserialized into a typed asset object that can be used by the application.
§Arguments
bytes- The raw byte data to deserialize into an assetcontext- Optional context providing access to asset manager state and configuration during the loading process
§Returns
The loaded asset data on success, or an error if loading failed.
§Errors
Returns an error if:
- Deserialization of the byte data fails
- The data format is invalid or corrupted
- Any other error occurs during the loading process