pub trait AssetKey: Key + 'static {
type Asset: Send + Sync + 'static;
// Required method
fn asset_eq(old: &Self::Asset, new: &Self::Asset) -> bool;
}Expand description
Trait for asset keys that map to loadable assets.
Asset keys identify external resources (files, URLs, etc.) and define the type of asset they load. Assets are leaf nodes in the dependency graph - they have no dependencies but can be depended upon by queries.
Durability is specified when calling resolve_asset(), not on the key type.
§Example
ⓘ
use query_flow::{asset_key, AssetKey};
#[asset_key(asset = String)]
pub struct ConfigFile(pub PathBuf);
// Or manually:
pub struct TextureId(pub u32);
impl AssetKey for TextureId {
type Asset = ImageData;
fn asset_eq(old: &Self::Asset, new: &Self::Asset) -> bool {
old.bytes == new.bytes
}
}Required Associated Types§
Required Methods§
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.