pub struct ResourceStorage { /* private fields */ }Expand description
Storage for various resources identified by their TypeId.
Implementations§
Source§impl ResourceStorage
impl ResourceStorage
Sourcepub fn insert<R: Resource>(&mut self, resource: R)
pub fn insert<R: Resource>(&mut self, resource: R)
Inserts a new resource into the storage.
If a resource of the same type already exists, it will be replaced.
Sourcepub fn fetch_mut<R: Resource>(&mut self) -> &mut R
pub fn fetch_mut<R: Resource>(&mut self) -> &mut R
Retrieves a mutable reference to a resource of type R.
§Panics
Panics if the resource does not exist.
Sourcepub fn get<R: Resource + 'static>(&self) -> Option<&R>
pub fn get<R: Resource + 'static>(&self) -> Option<&R>
Retrieves an immutable reference to a resource of type R.
Returns Some(&R) if the resource exists, otherwise returns None.
Sourcepub fn get_mut<R: Resource + 'static>(&mut self) -> Option<&mut R>
pub fn get_mut<R: Resource + 'static>(&mut self) -> Option<&mut R>
Retrieves a mutable reference to a resource of type R.
Returns Some(&mut R) if the resource exists, otherwise returns None.
Trait Implementations§
Source§impl Debug for ResourceStorage
impl Debug for ResourceStorage
Auto Trait Implementations§
impl Freeze for ResourceStorage
impl !RefUnwindSafe for ResourceStorage
impl !Send for ResourceStorage
impl !Sync for ResourceStorage
impl Unpin for ResourceStorage
impl !UnwindSafe for ResourceStorage
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
Mutably borrows from an owned value. Read more