Trait veloren_common_assets::AssetExt

source ·
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§

source

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();
source

fn load_owned(specifier: &str) -> Result<Self, Error>

source

fn get_or_insert(specifier: &str, default: Self) -> AssetHandle<Self>

Provided Methods§

source

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.

source

fn load_or_insert_with( specifier: &str, default: impl FnOnce(Error) -> Self, ) -> AssetHandle<Self>

source

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");
source

fn load_expect_cloned(specifier: &str) -> Self
where 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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: Compound> AssetExt for T