AssetLoader

Trait AssetLoader 

Source
pub trait AssetLoader {
    // Required method
    fn load_asset(
        &self,
        handler: &mut dyn AssetCreationHandler,
        identifier: &str,
    ) -> Option<AnyHandle<dyn Any>>;
}
Expand description

An AssetLoader loads an asset given its name, with help from an AssetCreationHandler. Some AssetLoaders implement special behaviour, such as caching or combining multiple child loaders.

Required Methods§

Source

fn load_asset( &self, handler: &mut dyn AssetCreationHandler, identifier: &str, ) -> Option<AnyHandle<dyn Any>>

Load an asset with the given identifier.

Returns None if the asset could not be found or failed to serialize.

Implementations on Foreign Types§

Source§

impl AssetLoader for Vec<Box<dyn AssetLoader>>

A Vec<Box> or similar structure can act as a combined loader over its elements, querying them one by one. The boxed_vec! macro can help with this. Prefer this over the use of a CombinedLoader.

Source§

fn load_asset( &self, handler: &mut dyn AssetCreationHandler, identifier: &str, ) -> Option<AnyHandle<dyn Any>>

Source§

impl AssetLoader for HashMap<String, AnyHandle<dyn Any>>

A simple HashMap can act as a loader for a set of values in memory.

Source§

fn load_asset( &self, _handler: &mut dyn AssetCreationHandler, identifier: &str, ) -> Option<AnyHandle<dyn Any>>

Source§

impl AssetLoader for PathBuf

A PathBuf can act as a loader for files relative to the directory it points to.

Source§

fn load_asset( &self, handler: &mut dyn AssetCreationHandler, identifier: &str, ) -> Option<AnyHandle<dyn Any>>

Implementors§

Source§

impl<Loader> AssetLoader for CachedLoader<Loader>
where Loader: AssetLoader,

Implement AssetLoader for the CachedLoader.