Struct legion::Resources[][src]

pub struct Resources { /* fields omitted */ }

Resources container. Shared resources stored here can be retrieved in systems.

Implementations

impl Resources[src]

pub fn sync(&mut self) -> SyncResources<'_>[src]

Creates an accessor to resources which are Send and Sync, which itself can be sent between threads.

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<AtomicRef<'_, T>>[src]

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

Panics

Panics if the resource is already borrowed mutably.

pub fn get_mut<T: Resource>(&self) -> Option<AtomicRefMut<'_, 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
) -> AtomicRef<'_, 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
) -> AtomicRefMut<'_, 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) -> AtomicRef<'_, 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
) -> AtomicRefMut<'_, 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) -> AtomicRef<'_, 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
) -> AtomicRefMut<'_, 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

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]

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

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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> Pointable for T

type Init = T

The type for initializers.

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.