AssetCacheExt

Trait AssetCacheExt 

Source
pub trait AssetCacheExt: Sealed {
    // Required methods
    fn ggez_load<T>(&self, context: &mut Context, id: &str) -> GameResult<T>
       where T: GgezAsset;
    fn ggez_get<T>(&self, context: &mut Context, id: &str) -> GameResult<T>
       where T: GgezAsset;
    fn ggez_contains<T>(&self, id: &str) -> bool
       where T: GgezAsset;
    fn ggez_reload_watcher<T>(&self, id: &str) -> Option<ReloadWatcher<'_>>
       where T: GgezAsset;
    fn set_font(
        &self,
        context: &mut Context,
        name: &str,
        id: &str,
    ) -> GameResult<()>;
}
Expand description

An extension trait for AssetCache.

This enables to easily use types for ggez.

Note that unlike other AssetCache methods that return a Handle, these methods directly return the requested type.

Required Methods§

Source

fn ggez_load<T>(&self, context: &mut Context, id: &str) -> GameResult<T>
where T: GgezAsset,

Gets an asset from the cache, and loads it from the source (usually the filesystem) if it was not found.

Source

fn ggez_get<T>(&self, context: &mut Context, id: &str) -> GameResult<T>
where T: GgezAsset,

Gets an asset from the cache and returns an errors if it was not found.

Source

fn ggez_contains<T>(&self, id: &str) -> bool
where T: GgezAsset,

Returns true if an asset is present in the cache.

Source

fn ggez_reload_watcher<T>(&self, id: &str) -> Option<ReloadWatcher<'_>>
where T: GgezAsset,

Returns a ReloadWatcher to watch changes of an asset.

Returns None if the asset is not in the cache.

Source

fn set_font( &self, context: &mut Context, name: &str, id: &str, ) -> GameResult<()>

Add a font to ggez with the given name, loaded from the given id.

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§