pub struct ResourceStorage { /* private fields */ }
Expand description
Storage for various resources identified by their TypeId
.
Implementations§
Source§impl ResourceStorage
impl ResourceStorage
Sourcepub fn new() -> ResourceStorage
pub fn new() -> ResourceStorage
Creates a new, empty ResourceStorage
.
Sourcepub fn insert<R>(&mut self, resource: R)where
R: Resource,
pub fn insert<R>(&mut self, resource: R)where
R: Resource,
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>(&mut self) -> &mut Rwhere
R: Resource,
pub fn fetch_mut<R>(&mut self) -> &mut Rwhere
R: Resource,
Retrieves a mutable reference to a resource of type R
.
§Panics
Panics if the resource does not exist.
Sourcepub fn get<R>(&self) -> Option<&R>where
R: Resource + 'static,
pub fn get<R>(&self) -> Option<&R>where
R: Resource + 'static,
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>(&mut self) -> Option<&mut R>where
R: Resource + 'static,
pub fn get_mut<R>(&mut self) -> Option<&mut R>where
R: Resource + 'static,
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
Source§impl Default for ResourceStorage
impl Default for ResourceStorage
Source§fn default() -> ResourceStorage
fn default() -> ResourceStorage
Returns the “default value” for a type. Read more
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