Struct amethyst_assets::Cache
source · pub struct Cache<A> { /* private fields */ }
Expand description
A simple cache for asset handles of type A
.
This stores WeakHandle
, so it doesn’t keep the assets alive.
Implementations
sourceimpl<A> Cache<A>where
A: Clone,
impl<A> Cache<A>where
A: Clone,
sourcepub fn insert<K: Into<String>>(
&mut self,
key: K,
asset: &Handle<A>
) -> Option<WeakHandle<A>>
pub fn insert<K: Into<String>>(
&mut self,
key: K,
asset: &Handle<A>
) -> Option<WeakHandle<A>>
Inserts an asset with a given key
and returns the old value (if any).
sourcepub fn get<K>(&self, key: &K) -> Option<Handle<A>>where
K: ?Sized + Hash + Eq,
String: Borrow<K>,
pub fn get<K>(&self, key: &K) -> Option<Handle<A>>where
K: ?Sized + Hash + Eq,
String: Borrow<K>,
Retrieves an asset handle using a given key
.
sourcepub fn clear_dead<F>(&mut self)
pub fn clear_dead<F>(&mut self)
Deletes all cached handles which are invalid.
Trait Implementations
Auto Trait Implementations
impl<A> RefUnwindSafe for Cache<A>where
A: RefUnwindSafe,
impl<A> Send for Cache<A>where
A: Send,
impl<A> Sync for Cache<A>where
A: Sync,
impl<A> Unpin for Cache<A>where
A: Unpin,
impl<A> UnwindSafe for Cache<A>where
A: UnwindSafe,
Blanket Implementations
impl<T> Any for Twhere
T: Any,
impl<T> Any for Twhere
T: Any,
fn get_type_id(&self) -> TypeId
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Tries to create the default.
fn unwrap_default() -> Self
fn unwrap_default() -> Self
Calls
try_default
and panics on an error case.