Module assets_manager::asset
source · Expand description
Values loadable from a cache.
§Asset kinds
In assets_manager
, assets are stored in an AssetCache
, and are usually
loaded from a Source
, a file system abstraction. Most of the I/O with
the source is handled by assets_manager
, so you can focus on the rest.
This crate defines several kinds of assets, that have different use cases:
- The most common,
Asset
s, that are loaded from a single file. AnAsset
gives a way to get a Rust value from raw bytes. This is nothing more than sugar on top ofCompound
. Compound
are created by loading other assets and composing them. They can also read sources directly.Storable
is the widest category: everything'static
type can fit in it. Values of types that implementStorable
can be inserted in a cache, but provide no way to construct them.
Additionnally, DirLoadable
assets can be loaded by directory, eventually
recursively. All Asset
types implement this trait out of the box, but it
can be extended to work with any Compound
, though it requires a custom
definition.
§Hot-reloading
Each asset is reloading when any file or directory it reads is modified, or when a asset it depends on is reloaded itself.
Additionally, one can explicitly disable hot-reloading for a type.
Note that hot-reloading is not atomic: if asset A
depends on B
, you can
observe a state where B
is reloaded but A
is not reloaded yet.
Additionally, if A
fails to reload, the inconsistent state is kept as is.
Structs§
- Bmp
bmp
An asset to load BMP images. - Flac
flac
Load FLAC sounds - Gltf
gltf
Loads glTF 3D assets. - Jpeg
jpeg
An asset to load JPEG images. - Json
json
Loads a value from a RON file. - Mp3
mp3
Load MP3 sounds - Png
png
An asset to load PNG images. - Ron
ron
Loads a value from a JSON file. - Toml
toml
Loads a value from a TOML file. - Vorbis
vorbis
Load Vorbis sounds - Wav
wav
Load WAV sounds - Webp
webp
An asset to load WebP images. - Yaml
yaml
Loads a value from a YAML file.
Traits§
- An asset is a type loadable from raw bytes.
- An asset type that can load other kinds of assets.
- Assets that are loadable from directories
- Mark a type as not being hot-reloaded.
- Trait marker to store values in a cache.