Module assets_manager::source

source ·
Expand description

Bytes sources to load assets from.

This module contains the trait Source, which allows to specify how the files containing the assets are loaded. The main usage usage of this trait is with an AssetCache.

This module also contains three built-in sources: FileSystem, Zip and Embedded.

§Hot-reloading

Hot-reloading enable assets to be reloaded automatically when the source it was loaded from was modified. It requires the Source to support it. The built-in FileSystem source supports it out of the box.

§Using a different source depending on the target platform

There is no file system on WebAssembly, so you can for example choose to embed your assets on this platform:

use assets_manager::{AssetCache, source};

#[cfg(not(target_arch = "wasm32"))]
let source = source::FileSystem::new("assets")?;

#[cfg(target_arch = "wasm32")]
let source = source::Embedded::from(source::embed!("assets"));

let cache = AssetCache::with_source(source);

Macros§

  • embedembedded
    Embed a directory in the binary

Structs§

Enums§

Traits§

  • Bytes sources to load assets from.