[−][src]Trait assets_manager::Asset
An asset is a type loadable from a file.
Asset
s can loaded and retreived by an AssetCache
.
Example
Suppose you make a physics simulutation, and you positions and speeds in a Bincode-encoded files, with extension ".data"
use assets_manager::{Asset, loader}; use serde::Deserialize; #[derive(Deserialize)] struct Vector { x: f32, y: f32, z: f32, } #[derive(Deserialize)] struct World { pos: Vec<Vector>, speed: Vec<Vector>, } impl Asset for World { const EXT: &'static str = "data"; type Loader = loader::BincodeLoader; }
Associated Types
type Loader: Loader<Self>
Specifies a way to to convert raw bytes into the asset.
See module loader
for implementations of common conversions.
Associated Constants
const EXT: &'static str
The extension used by the asset files from the given asset type.
Use ""
for no extension.
Provided methods
fn load_from_raw(content: Vec<u8>) -> Result<Self, AssetError>
Create an asset value from raw parts.
This function is not meant to be used directly, but rather to
be overriden if you don't want or need to implement Loader
.
In that case, you should use CustomLoader
as Loader