Skip to main content

AssetHandle

Trait AssetHandle 

Source
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§

Source

fn load_handle(&self) -> LoadHandle

Returns the LoadHandle of this asset handle.

Provided Methods§

Source

fn load_status(&self, loader: &Loader) -> LoadStatus

Returns the load status of the asset.

§Parameters
  • loader: Loader that is loading the asset.
§Type Parameters
  • L: Asset loader type.
Source

fn asset<'a, T, S: TypedAssetStorage<T>>(&self, storage: &'a S) -> Option<&'a T>
where Self: Sized,

Returns an immutable reference to the asset if it is committed.

§Parameters
  • storage: Asset storage.
Source

fn asset_version<T, S: TypedAssetStorage<T>>(&self, storage: &S) -> Option<u32>
where Self: Sized,

Returns the version of the asset if it is committed.

§Parameters
  • storage: Asset storage.
Source

fn asset_with_version<'a, T, S: TypedAssetStorage<T>>( &self, storage: &'a S, ) -> Option<(&'a T, u32)>
where Self: Sized,

Returns the asset with the given version if it is committed.

§Parameters
  • storage: Asset storage.
Source

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.

Implementors§