pub trait AssetHandle {
// Required method
fn load_handle(&self) -> LoadHandle;
// Provided methods
fn load_status(&self, loader: &Loader) -> LoadStatus { ... }
fn asset<'a, T, S: TypedAssetStorage<T>>(
&self,
storage: &'a S,
) -> Option<&'a T>
where Self: Sized { ... }
fn asset_version<T, S: TypedAssetStorage<T>>(
&self,
storage: &S,
) -> Option<u32>
where Self: Sized { ... }
fn asset_with_version<'a, T, S: TypedAssetStorage<T>>(
&self,
storage: &'a S,
) -> Option<(&'a T, u32)>
where Self: Sized { ... }
fn downgrade(&self) -> WeakHandle { ... }
}Expand description
The contract of an asset handle.
There are two types of asset handles:
- Typed –
Handle<T>: When the asset’s type is known when loading. - Generic –
GenericHandle: When only the asset’s UUID is known when loading.
Required Methods§
Sourcefn load_handle(&self) -> LoadHandle
fn load_handle(&self) -> LoadHandle
Returns the LoadHandle of this asset handle.
Provided Methods§
Sourcefn load_status(&self, loader: &Loader) -> LoadStatus
fn load_status(&self, loader: &Loader) -> LoadStatus
Sourcefn asset<'a, T, S: TypedAssetStorage<T>>(&self, storage: &'a S) -> Option<&'a T>where
Self: Sized,
fn asset<'a, T, S: TypedAssetStorage<T>>(&self, storage: &'a S) -> Option<&'a T>where
Self: Sized,
Sourcefn asset_version<T, S: TypedAssetStorage<T>>(&self, storage: &S) -> Option<u32>where
Self: Sized,
fn asset_version<T, S: TypedAssetStorage<T>>(&self, storage: &S) -> Option<u32>where
Self: Sized,
Sourcefn asset_with_version<'a, T, S: TypedAssetStorage<T>>(
&self,
storage: &'a S,
) -> Option<(&'a T, u32)>where
Self: Sized,
fn asset_with_version<'a, T, S: TypedAssetStorage<T>>(
&self,
storage: &'a S,
) -> Option<(&'a T, u32)>where
Self: Sized,
Sourcefn downgrade(&self) -> WeakHandle
fn downgrade(&self) -> WeakHandle
Downgrades this handle into a WeakHandle.
Be aware that if there are no longer any strong handles to the asset, then the underlying asset may be freed at any time.