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§
Sourcefn ggez_load<T>(&self, context: &mut Context, id: &str) -> GameResult<T>where
T: GgezAsset,
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.
Sourcefn ggez_get<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,
Gets an asset from the cache and returns an errors if it was not found.
Sourcefn ggez_contains<T>(&self, id: &str) -> boolwhere
T: GgezAsset,
fn ggez_contains<T>(&self, id: &str) -> boolwhere
T: GgezAsset,
Returns true if an asset is present in the cache.
Sourcefn ggez_reload_watcher<T>(&self, id: &str) -> Option<ReloadWatcher<'_>>where
T: GgezAsset,
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.
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.