[]Struct acute_ecs::systems::prelude::Resources

pub struct Resources { /* fields omitted */ }

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

Returns true if type T exists in the store. Otherwise, returns false

pub fn insert<T>(&mut self, value: T) where
    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

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

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

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

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

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

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

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

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

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

impl Default for Resources

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Component for T where
    T: 'static + Send + Sync

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Resource for T where
    T: 'static + Send + Sync

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.