[−]Struct acute_ecs::systems::prelude::Resources
Resources container. This container stores its underlying resources in a FxHashMap
keyed on
ResourceTypeId
. This means that the ID's used in this storage will not persist between recompiles.
Implementations
impl Resources
pub fn contains<T>(&self) -> bool where
T: Resource,
T: Resource,
Returns true
if type T
exists in the store. Otherwise, returns false
pub fn insert<T>(&mut self, value: T) where
T: Resource,
T: Resource,
Inserts the instance of T
into the store. If the type already exists, it will be silently
overwritten. If you would like to retain the instance of the resource that already exists,
call remove
first to retrieve it.
pub fn remove<T>(&mut self) -> Option<T> where
T: Resource,
T: Resource,
Removes the type T
from this store if it exists.
Returns
If the type T
was stored, the inner instance of T is returned. Otherwise,
None`
pub fn get<T>(&self) -> Option<Fetch<'_, T>> where
T: Resource,
T: Resource,
Retrieve an immutable reference to T
from the store if it exists. Otherwise, return None
pub fn get_mut<T>(&self) -> Option<FetchMut<'_, T>> where
T: Resource,
T: Resource,
Retrieve a mutable reference to T
from the store if it exists. Otherwise, return None
pub fn get_or_insert_with<T, F>(&mut self, f: F) -> Option<Fetch<'_, T>> where
F: FnOnce() -> T,
T: Resource,
F: FnOnce() -> T,
T: Resource,
Attempts to retrieve an immutable reference to T
from the store. If it does not exist,
the closure f
is called to construct the object and it is then inserted into the store.
pub fn get_mut_or_insert_with<T, F>(&mut self, f: F) -> Option<FetchMut<'_, T>> where
F: FnOnce() -> T,
T: Resource,
F: FnOnce() -> T,
T: Resource,
Attempts to retrieve a mutable reference to T
from the store. If it does not exist,
the closure f
is called to construct the object and it is then inserted into the store.
pub fn get_or_insert<T>(&mut self, value: T) -> Option<Fetch<'_, T>> where
T: Resource,
T: Resource,
Attempts to retrieve an immutable reference to T
from the store. If it does not exist,
the provided value is inserted and then a reference to it is returned.
pub fn get_mut_or_insert<T>(&mut self, value: T) -> Option<FetchMut<'_, T>> where
T: Resource,
T: Resource,
Attempts to retrieve a mutable reference to T
from the store. If it does not exist,
the provided value is inserted and then a reference to it is returned.
pub fn get_or_default<T>(&mut self) -> Option<Fetch<'_, T>> where
T: Resource + Default,
T: Resource + Default,
Attempts to retrieve an immutable reference to T
from the store. If it does not exist,
the default constructor for T
is called.
T
must implement Default
for this method.
pub fn get_mut_or_default<T>(&mut self) -> Option<FetchMut<'_, T>> where
T: Resource + Default,
T: Resource + Default,
Attempts to retrieve a mutable reference to T
from the store. If it does not exist,
the default constructor for T
is called.
T
must implement Default
for this method.
pub fn merge(&mut self, other: Resources)
Performs merging of two resource storages, which occurs during a world merge. This merge will retain any already-existant resources in the local world, while moving any new resources from the source world into this one, consuming the resources.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Resources
impl Send for Resources
impl Sync for Resources
impl Unpin for Resources
impl !UnwindSafe for Resources
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Component for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T> Downcast for T where
T: Any,
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Send + Sync + Any,
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,