pub trait AssetLoader: Send + Sync + 'static {
    type Asset: Asset;
    type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>;
    type Error: Into<Box<dyn Error + Send + Sync>>;

    // Required method
    fn load<'a>(
        &'a self,
        reader: &'a mut (dyn AsyncRead + Send + Sync + Unpin + '_),
        settings: &'a Self::Settings,
        load_context: &'a mut LoadContext<'_>
    ) -> Pin<Box<dyn Future<Output = Result<Self::Asset, Self::Error>> + Send + 'a>>;

    // Provided method
    fn extensions(&self) -> &[&str] { ... }
}
Expand description

Loads an Asset from a given byte Reader. This can accept AssetLoader::Settings, which configure how the Asset should be loaded.

Required Associated Types§

source

type Asset: Asset

The top level Asset loaded by this AssetLoader.

source

type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>

The settings type used by this AssetLoader.

source

type Error: Into<Box<dyn Error + Send + Sync>>

The type of error which could be encountered by this loader.

Required Methods§

source

fn load<'a>( &'a self, reader: &'a mut (dyn AsyncRead + Send + Sync + Unpin + '_), settings: &'a Self::Settings, load_context: &'a mut LoadContext<'_> ) -> Pin<Box<dyn Future<Output = Result<Self::Asset, Self::Error>> + Send + 'a>>

Asynchronously loads AssetLoader::Asset (and any other labeled assets) from the bytes provided by Reader.

Provided Methods§

source

fn extensions(&self) -> &[&str]

Returns a list of extensions supported by this AssetLoader, without the preceding dot. Note that users of this AssetLoader may choose to load files with a non-matching extension.

Implementations on Foreign Types§

source§

impl AssetLoader for ()

The () loader should never be called. This implementation exists to make the meta format nicer to work with.

§

type Asset = ()

§

type Settings = ()

§

type Error = Error

source§

fn load<'a>( &'a self, _reader: &'a mut (dyn AsyncRead + Send + Sync + Unpin + '_), _settings: &'a <() as AssetLoader>::Settings, _load_context: &'a mut LoadContext<'_> ) -> Pin<Box<dyn Future<Output = Result<<() as AssetLoader>::Asset, <() as AssetLoader>::Error>> + Send + 'a>>

source§

fn extensions(&self) -> &[&str]

Implementors§