pub trait AssetLoader<A: Asset>:
Send
+ Sync
+ 'static {
// Required methods
fn load(&self, bytes: &[u8], path: &AssetPath) -> Result<A, String>;
fn extensions(&self) -> &[&str];
}Expand description
Trait for loading raw bytes into a concrete Asset type.
Each asset format (PNG, WAV, GLSL, etc.) has one loader. Loaders are
stateless by design; mutable state lives in AssetServer.
§Type parameter
A — the Asset type produced by this loader.
Required Methods§
Sourcefn load(&self, bytes: &[u8], path: &AssetPath) -> Result<A, String>
fn load(&self, bytes: &[u8], path: &AssetPath) -> Result<A, String>
Load an asset from the given byte slice.
path is provided for diagnostic messages; the loader must not
perform additional I/O itself.
Returns Ok(asset) on success, Err(message) on failure.
Sourcefn extensions(&self) -> &[&str]
fn extensions(&self) -> &[&str]
Returns the file extensions this loader handles (without the dot).
Examples: &["png", "jpg"], &["glsl", "vert", "frag"].