Trait 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.

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.

Implementors§

Source§

impl<T: Compound> AssetExt for T