pub trait Asset:
Send
+ Sync
+ 'static { }Expand description
A marker trait for types that can be managed by the asset system.
This trait’s primary purpose is to categorize a type, making it eligible for
use within the engine’s asset infrastructure (e.g., in a Handle<T>).
The supertraits enforce critical safety guarantees:
Send+Sync: The asset type can be safely shared and sent between threads. This is essential for background loading.'static: The asset type does not contain any non-static references, ensuring it can be stored for the lifetime of the application.
§Examples
use khora_core::asset::Asset;
// A simple struct representing a texture.
struct Texture {
// ... fields
}
// By implementing Asset, `Texture` can now be used by the asset system.
impl Asset for Texture {}Implementations on Foreign Types§
impl Asset for Box<dyn Material>
This is the key to our type-erased material handle system. We explicitly tell the compiler that a boxed, dynamic Material trait object can itself be treated as a valid Asset. This allows it to be stored inside an AssetHandle.