[−][src]Struct resources::Resources
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
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> Downcast for T where
T: Any, [src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>[src]
fn as_any(&self) -> &(dyn Any + 'static)[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any, [src]
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, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = !
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>,