Struct zengine_asset::Assets
source · [−]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
sourceimpl<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> 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
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
sourceimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
. Read moresourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn 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. Read moresourcefn 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. Read more