Trait AssetLoader

Source
pub trait AssetLoader<A: Asset> {
    // Required method
    fn load(&self, bytes: &[u8]) -> Result<A, Box<dyn Error + Send + Sync>>;
}
Expand description

A trait for types that can load a specific kind of asset from a byte slice.

This represents the “Data Plane” part of asset loading. Implementors of this trait are responsible for the potentially CPU-intensive work of parsing and decoding raw file data into a usable, engine-ready asset type.

Each AssetLoader is specialized for a single asset type A.

Required Methods§

Source

fn load(&self, bytes: &[u8]) -> Result<A, Box<dyn Error + Send + Sync>>

Parses a byte slice and converts it into an instance of the asset A.

§Parameters
  • bytes: The raw byte data read from an asset file.
§Returns

A Result containing the loaded asset on success, or a boxed dynamic error on failure. The error must be thread-safe.

Implementors§