Skip to main content

Module loader

Module loader 

Source
Expand description

How a source path becomes a decoded asset.

AssetLoader is the extension point: a loader claims one or more file extensions, declares which AssetKind it produces, and turns one LoadContext into a LoadedAsset. AssetLoaders is the registry the crate::AssetServer resolves through, and the built-in image and SVG paths are ordinary loaders registered into it by AssetLoaders::default.

The shape follows Bevy’s AssetLoader, adapted to how this crate loads:

  • Loading is synchronous. A load runs on the decode worker pool, so a loader blocks its worker thread instead of awaiting.
  • A load is described by a path plus, optionally, bytes an crate::AssetSource already resolved. It is not a byte stream, because the built-in image path hands the path to image::open rather than reading the file itself.
  • The loader is resolved on the main thread at enqueue time and travels with the job, so registering a loader never has to be synchronised with a running worker.

Structs§

AssetLoaders
Extension-keyed loader registry.
LoadContext
Everything a loader is given for one load.

Enums§

AssetKind
Which family of asset a loader produces.
LoadedAsset
One successfully loaded asset, tagged by family.

Traits§

AssetLoader
Turns one source path into a decoded asset.

Functions§

asset_extension
The lowercase extension used for loader lookup.