Struct amethyst_assets::AssetStorage
source · pub struct AssetStorage<A: Asset> { /* private fields */ }
Expand description
An asset storage, storing the actual assets and allocating handles to them.
Implementations
sourceimpl<A: Asset> AssetStorage<A>
impl<A: Asset> AssetStorage<A>
sourcepub fn clone_asset(&mut self, handle: &Handle<A>) -> Option<Handle<A>>where
A: Clone,
pub fn clone_asset(&mut self, handle: &Handle<A>) -> Option<Handle<A>>where
A: Clone,
When cloning an asset handle, you’ll get another handle,
but pointing to the same asset. If you instead want to
indeed create a new asset, you can use this method.
Note however, that it needs a mutable borrow of self
,
so it can’t be used in parallel.
sourcepub fn get_mut(&mut self, handle: &Handle<A>) -> Option<&mut A>
pub fn get_mut(&mut self, handle: &Handle<A>) -> Option<&mut A>
Get an asset mutably from a given asset handle.
sourcepub fn process<F>(
&mut self,
f: F,
frame_number: u64,
pool: &ThreadPool,
strategy: Option<&HotReloadStrategy>
)where
F: FnMut(A::Data) -> Result<ProcessingState<A>>,
pub fn process<F>(
&mut self,
f: F,
frame_number: u64,
pool: &ThreadPool,
strategy: Option<&HotReloadStrategy>
)where
F: FnMut(A::Data) -> Result<ProcessingState<A>>,
Process finished asset data and maintain the storage.
sourcepub fn process_custom_drop<F, D>(
&mut self,
f: F,
drop_fn: D,
frame_number: u64,
pool: &ThreadPool,
strategy: Option<&HotReloadStrategy>
)where
D: FnMut(A),
F: FnMut(A::Data) -> Result<ProcessingState<A>>,
pub fn process_custom_drop<F, D>(
&mut self,
f: F,
drop_fn: D,
frame_number: u64,
pool: &ThreadPool,
strategy: Option<&HotReloadStrategy>
)where
D: FnMut(A),
F: FnMut(A::Data) -> Result<ProcessingState<A>>,
Process finished asset data and maintain the storage.
This calls the drop_fn
closure for assets that were removed from the storage.
Trait Implementations
sourceimpl<A: Asset> Default for AssetStorage<A>
impl<A: Asset> Default for AssetStorage<A>
Auto Trait Implementations
impl<A> !RefUnwindSafe for AssetStorage<A>
impl<A> Send for AssetStorage<A>
impl<A> Sync for AssetStorage<A>
impl<A> Unpin for AssetStorage<A>where
A: Unpin,
<A as Asset>::Data: Unpin,
impl<A> !UnwindSafe for AssetStorage<A>
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.