pub trait AssetExt:
Sized
+ Send
+ Sync
+ 'static {
// Required methods
fn load(specifier: &str) -> Result<AssetHandle<Self>, Error>;
fn load_owned(specifier: &str) -> Result<Self, Error>;
fn get_or_insert(specifier: &str, default: Self) -> AssetHandle<Self>;
// Provided methods
fn load_cloned(specifier: &str) -> Result<Self, Error>
where Self: Clone { ... }
fn load_or_insert_with(
specifier: &str,
default: impl FnOnce(Error) -> Self,
) -> AssetHandle<Self> { ... }
fn load_expect(specifier: &str) -> AssetHandle<Self> { ... }
fn load_expect_cloned(specifier: &str) -> Self
where Self: Clone { ... }
}
Expand description
The Asset trait, which is implemented by all structures that have their data stored in the filesystem.
Required Methods§
Sourcefn load(specifier: &str) -> Result<AssetHandle<Self>, Error>
fn load(specifier: &str) -> Result<AssetHandle<Self>, Error>
Function used to load assets from the filesystem or the cache. Example usage:
use veloren_common_assets::{AssetExt, Image};
let my_image = Image::load("core.ui.backgrounds.city").unwrap();
fn load_owned(specifier: &str) -> Result<Self, Error>
fn get_or_insert(specifier: &str, default: Self) -> AssetHandle<Self>
Provided Methods§
Sourcefn load_cloned(specifier: &str) -> Result<Self, Error>where
Self: Clone,
fn load_cloned(specifier: &str) -> Result<Self, Error>where
Self: Clone,
Function used to load assets from the filesystem or the cache and return a clone.
fn load_or_insert_with( specifier: &str, default: impl FnOnce(Error) -> Self, ) -> AssetHandle<Self>
Sourcefn load_expect(specifier: &str) -> AssetHandle<Self>
fn load_expect(specifier: &str) -> AssetHandle<Self>
Function used to load essential assets from the filesystem or the cache. It will panic if the asset is not found. Example usage:
use veloren_common_assets::{AssetExt, Image};
let my_image = Image::load_expect("core.ui.backgrounds.city");
Sourcefn load_expect_cloned(specifier: &str) -> Selfwhere
Self: Clone,
fn load_expect_cloned(specifier: &str) -> Selfwhere
Self: Clone,
Function used to load essential assets from the filesystem or the cache and return a clone. It will panic if the asset is not found.
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.