Trait bones_asset::AssetIo
source · pub trait AssetIo: Sync + Send {
// Required methods
fn enumerate_packs(&self) -> BoxedFuture<Result<Vec<String>>>;
fn load_file(&self, loc: AssetLocRef<'_>) -> BoxedFuture<Result<Vec<u8>>>;
// 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§
sourcefn enumerate_packs(&self) -> BoxedFuture<Result<Vec<String>>>
fn enumerate_packs(&self) -> BoxedFuture<Result<Vec<String>>>
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.
sourcefn load_file(&self, loc: AssetLocRef<'_>) -> BoxedFuture<Result<Vec<u8>>>
fn load_file(&self, loc: AssetLocRef<'_>) -> BoxedFuture<Result<Vec<u8>>>
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§
sourcefn watch(&self, change_sender: Sender<ChangedAsset>) -> bool
fn watch(&self, change_sender: Sender<ChangedAsset>) -> bool
Subscribe to asset changes.
Returns true
if this AssetIo
implementation supports watching for changes.