Struct assets_manager::UntypedHandle

source ·
pub struct UntypedHandle { /* private fields */ }
Expand description

A untyped handle on an asset.

This is an type-erased version of Handle. As with dyn Any, the underlying type can be queried at runtime.

Implementations§

source§

impl UntypedHandle

source

pub fn read(&self) -> AssetReadGuard<'_, dyn Any + Send + Sync>

Locks the pointed asset for reading.

If T implements NotHotReloaded or if hot-reloading is disabled, no reloading can occur so there is no actual lock. In these cases, calling this function does not involve synchronisation.

Returns a RAII guard which will release the lock once dropped.

source

pub fn id(&self) -> &SharedString

Returns the id of the asset.

source

pub fn is<T: 'static>(&self) -> bool

Returns true if the inner type is the same as T.

source

pub fn downcast_ref<T: Storable>(&self) -> Option<&Handle<T>>

Returns a handle to the asset if it is of type T.

source

pub fn reload_watcher(&self) -> ReloadWatcher<'_>

Returns a ReloadWatcher that can be used to check whether this asset was reloaded.

See Handle::reload_watcher for details.

source

pub fn last_reload_id(&self) -> ReloadId

Returns the last ReloadId associated with this asset.

It is only meaningful when compared to other ReloadIds returned by the same handle or to ReloadId::NEVER.

source

pub fn reloaded_global(&self) -> bool

Returns true if the asset has been reloaded since last call to this method with any handle on this asset.

Note that this method and reload_watcher are totally independant, and the result of the two functions do not depend on whether the other was called.

Trait Implementations§

source§

impl Debug for UntypedHandle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more