pub struct Assets<T: Asset> { /* private fields */ }Expand description
A Resource that stores Assets of a given type
Each asset is mapped by an unique HandleId, allowing any Handle with the same
HandleId to access it.
One asset remain loaded as long as a Strong handle to that asset exists.
To get a reference to an asset without forcing it to stay loadid you can use a Weak handle
Implementations§
Source§impl<T: Asset> Assets<T>
impl<T: Asset> Assets<T>
Sourcepub fn contains(&self, handle: &Handle<T>) -> bool
pub fn contains(&self, handle: &Handle<T>) -> bool
Checks if an asset exists for the given handle
Sourcepub fn get(&self, handle: &Handle<T>) -> Option<&T>
pub fn get(&self, handle: &Handle<T>) -> Option<&T>
Get an asset reference for the given handle
Sourcepub fn get_mut(&mut self, handle: &Handle<T>) -> Option<&mut T>
pub fn get_mut(&mut self, handle: &Handle<T>) -> Option<&mut T>
Get a mutable asset reference for the given handle
Sourcepub fn iter(&self) -> impl Iterator<Item = (&HandleId, &T)>
pub fn iter(&self) -> impl Iterator<Item = (&HandleId, &T)>
Gets an iterator over the assets in the storage
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&HandleId, &mut T)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&HandleId, &mut T)>
Gets a mutable iterator over the assets in the storage
Sourcepub fn add(&mut self, asset: T) -> Handle<T>
pub fn add(&mut self, asset: T) -> Handle<T>
Add an asset to the storage returning a strong handle to that asset
Sourcepub fn set(&mut self, handle: Handle<T>, asset: T) -> Handle<T>
pub fn set(&mut self, handle: Handle<T>, asset: T) -> Handle<T>
Add/Replace the asset pointed by the given handle returning a strong handle to that asset
Sourcepub fn set_untracked(&mut self, handle_id: HandleId, asset: T)
pub fn set_untracked(&mut self, handle_id: HandleId, asset: T)
Add/Replace the asset pointed by the given handle
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Assets<T>
impl<T> RefUnwindSafe for Assets<T>where
T: RefUnwindSafe,
impl<T> Send for Assets<T>
impl<T> Sync for Assets<T>
impl<T> Unpin for Assets<T>where
T: Unpin,
impl<T> UnwindSafe for Assets<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.