bevy_asset

Trait AssetLoader

Source
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 + 'static>>;

    // Required method
    fn load(
        &self,
        reader: &mut dyn Reader,
        settings: &Self::Settings,
        load_context: &mut LoadContext<'_>,
    ) -> impl ConditionalSendFuture<Output = Result<Self::Asset, Self::Error>>;

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

This trait is generally used in concert with AssetReader to load assets from a byte source.

For a complementary version of this trait that can save assets, see AssetSaver.

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 + 'static>>

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

Required Methods§

Source

fn load( &self, reader: &mut dyn Reader, settings: &Self::Settings, load_context: &mut LoadContext<'_>, ) -> impl ConditionalSendFuture<Output = Result<Self::Asset, Self::Error>>

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

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.

Source§

type Asset = ()

Source§

type Settings = ()

Source§

type Error = Error

Source§

async fn load( &self, _reader: &mut dyn Reader, _settings: &Self::Settings, _load_context: &mut LoadContext<'_>, ) -> Result<Self::Asset, Self::Error>

Source§

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

Implementors§