Trait assets_manager::asset::Compound

source ·
pub trait Compound: Sized + Send + Sync + 'static {
    const HOT_RELOADED: bool = true;

    // Required method
    fn load(cache: AnyCache<'_>, id: &SharedString) -> Result<Self, BoxedError>;
}
Expand description

An asset type that can load other kinds of assets.

Compounds can be loaded and retrieved by an AssetCache.

A Compound often needs to reference other assets, but Compound requires 'static and a Handle is borrowed. See top-level documentation for workarounds.

Note that all Assets implement Compound.

§Hot-reloading

Any asset loaded from the given cache is registered as a dependency of the Compound. When the former is reloaded, the latter will be reloaded too. An asset cannot depend on itself, or it may cause deadlocks to happen.

To opt out of dependencies recording, use AssetCache::no_record.

Provided Associated Constants§

source

const HOT_RELOADED: bool = true

If false, disable hot-reloading for assets of this type (true by default). If so, you may want to implement NotHotReloaded for this type to enable additional functions.

Required Methods§

source

fn load(cache: AnyCache<'_>, id: &SharedString) -> Result<Self, BoxedError>

Loads an asset from the cache.

This function should not perform any kind of I/O: such concern should be delegated to Assets.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Compound for Arc<T>
where T: Compound,

source§

fn load(cache: AnyCache<'_>, id: &SharedString) -> Result<Self, BoxedError>

source§

const HOT_RELOADED: bool = T::HOT_RELOADED

Implementors§

source§

impl Compound for Gltf

Available on crate feature gltf only.
source§

impl<T> Compound for Directory<T>
where T: DirLoadable,

source§

impl<T> Compound for RecursiveDirectory<T>
where T: DirLoadable,

source§

impl<T> Compound for T
where T: Asset,

source§

const HOT_RELOADED: bool = Self::HOT_RELOADED

source§

impl<U: Compound, T: Send + Sync + 'static> Compound for OnceInitCell<Option<U>, T>

source§

const HOT_RELOADED: bool = U::HOT_RELOADED

source§

impl<U: Compound, T: Send + Sync + 'static> Compound for OnceInitCell<U, T>

source§

const HOT_RELOADED: bool = U::HOT_RELOADED