[][src]Struct legion_systems::resource::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[src]

pub fn contains<T: Resource>(&self) -> bool[src]

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

pub fn insert<T: Resource>(&mut self, value: T)[src]

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: Resource>(&mut self) -> Option<T>[src]

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: Resource>(&self) -> Option<Fetch<T>>[src]

Retrieve an immutable reference to T from the store if it exists. Otherwise, return None

pub fn get_mut<T: Resource>(&self) -> Option<FetchMut<T>>[src]

Retrieve a mutable reference to T from the store if it exists. Otherwise, return None

pub fn get_or_insert_with<T: Resource, F: FnOnce() -> T>(
    &mut self,
    f: F
) -> Option<Fetch<T>>
[src]

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: Resource, F: FnOnce() -> T>(
    &mut self,
    f: F
) -> Option<FetchMut<T>>
[src]

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: Resource>(&mut self, value: T) -> Option<Fetch<T>>[src]

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: Resource>(
    &mut self,
    value: T
) -> Option<FetchMut<T>>
[src]

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: Resource + Default>(&mut self) -> Option<Fetch<T>>[src]

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: Resource + Default>(
    &mut self
) -> Option<FetchMut<T>>
[src]

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)[src]

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[src]

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
[src]

impl<T> Downcast for T where
    T: Any
[src]

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

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
[src]

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.