Skip to main content

extendable_assets/
asset_type.rs

1use crate::loader::AssetDataLoader;
2use crate::saver::AssetDataSaver;
3
4/// Defines how a specific type of asset should be loaded and saved.
5///
6/// Asset types provide the metadata and behavior for handling different kinds of assets.
7/// Each asset type has a unique name and provides factories for creating loaders and savers.
8pub trait AssetType: Send + Sync {
9    /// Returns the unique name identifier for this asset type.
10    fn name(&self) -> &str;
11
12    /// Creates a new loader instance for this asset type.
13    ///
14    /// The loader is responsible for converting raw bytes into asset data.
15    fn loader(&self) -> Box<dyn AssetDataLoader>;
16
17    /// Creates a new saver instance for this asset type.
18    ///
19    /// The saver is responsible for converting asset data back to raw bytes.
20    fn saver(&self) -> Box<dyn AssetDataSaver>;
21}