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.
Compound
s 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 Asset
s 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§
sourceconst HOT_RELOADED: bool = true
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§
sourcefn load(cache: AnyCache<'_>, id: &SharedString) -> Result<Self, BoxedError>
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 Asset
s.
Object Safety§
Implementations on Foreign Types§
source§impl<T> Compound for Arc<T>where
T: Compound,
impl<T> Compound for Arc<T>where
T: Compound,
fn load(cache: AnyCache<'_>, id: &SharedString) -> Result<Self, BoxedError>
const HOT_RELOADED: bool = T::HOT_RELOADED
Implementors§
impl Compound for Gltf
gltf
only.