Trait bones_framework::asset::AssetIo

source ·
pub trait AssetIo: Sync + Send {
    // Required methods
    fn enumerate_packs(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send>>;
    fn load_file(
        &self,
        loc: AssetLocRef<'_>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send>>;

    // Provided method
    fn watch(&self, change_sender: Sender<ChangedAsset>) -> bool { ... }
}
Expand description

AssetIo is a trait that is implemented for backends capable of loading all the games assets and returning the raw bytes stored in asset files.

Required Methods§

source

fn enumerate_packs( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send>>

List the names of the non-core asset pack folders that are installed.

These names, are not necessarily the names of the pack, but the names of the folders that they are located in. These names can be used to load files from the pack in the load_file() method.

source

fn load_file( &self, loc: AssetLocRef<'_>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send>>

Get the binary contents of an asset.

The pack_folder is the name of a folder returned by enumerate_packs(), or None to refer to the core pack.

Provided Methods§

source

fn watch(&self, change_sender: Sender<ChangedAsset>) -> bool

Subscribe to asset changes.

Returns true if this AssetIo implementation supports watching for changes.

Implementors§