[][src]Struct resources::Resources

pub struct Resources { /* fields omitted */ }

A Resource container, for storing at most one resource of each specific type.

Internally, this is a FxHashMap of TypeId to RwLock.

The lock is used in a non-blocking way; in fact, it's underlying implementation will panic instead of blocking.

Methods

impl Resources[src]

pub fn new() -> Self[src]

Creates an empty container. Functionally identical to default.

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

Returns true if a resource of type T exists in the container.

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

Inserts the given resource of type T into the container.

If a resource of this type was already present, it will be updated, and the original returned.

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

Removes the resource of type T from the container.

If a resource of this type was present in the container, it will be returned.

pub fn entry<T: Resource>(&mut self) -> Entry<T>[src]

Gets the type T's corresponding entry for in-place manipulation.

pub fn get<T: Resource>(&self) -> Result<Ref<T>, CantGetResource>[src]

Returns a reference to the stored resource of type T.

If such a resource is currently accessed mutably elsewhere, or is not present in the container, returns the appropriate error.

pub fn get_mut<T: Resource>(&self) -> Result<RefMut<T>, CantGetResource>[src]

Returns a mutable reference to the stored resource of type T.

If such a resource is currently accessed immutably or mutably elsewhere, or is not present in the container, returns the appropriate error.

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> 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, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

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.