[][src]Trait assets_manager::Asset

pub trait Asset: Sized + Send + Sync + 'static {
    type Loader: Loader<Self>;

    const EXT: &'static str;
}

An asset is a type loadable from a file.

Assets 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.

Loading content...

Associated Constants

const EXT: &'static str

The extension used by the asset files from the given asset type.

It must not contain the . caracter.

Use "" for no extension.

Loading content...

Implementors

Loading content...