Trait veloren_common_assets::Compound
pub trait Compound: Sized + Send + Sync + 'static {
const HOT_RELOADED: bool = true;
// Required method
fn load(
cache: AnyCache<'_>,
id: &SharedString,
) -> Result<Self, Box<dyn Error + Send + Sync>>;
}
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§
const HOT_RELOADED: bool = true
const HOT_RELOADED: bool = true
If false
, disable hot-reloading for assets of this type (true
by
default). This avoids having to lock the asset to read it (ie it makes
[Handle::read
] a noop)
Required Methods§
Object Safety§
This trait is not object safe.