Struct bones_render::prelude::Resources
source · pub struct Resources { /* private fields */ }Expand description
A collection of resources.
Resources is essentially a type-map
Implementations§
source§impl Resources
impl Resources
sourcepub fn init<T>(&mut self)where
T: TypedEcsData + Default,
pub fn init<T>(&mut self)where
T: TypedEcsData + Default,
Initialize a resource of type T by inserting it’s default value.
sourcepub fn insert<T>(&mut self, resource: T)where
T: TypedEcsData,
pub fn insert<T>(&mut self, resource: T)where
T: TypedEcsData,
sourcepub fn try_insert<T>(&mut self, resource: T) -> Result<(), EcsError>where
T: TypedEcsData,
pub fn try_insert<T>(&mut self, resource: T) -> Result<(), EcsError>where
T: TypedEcsData,
sourcepub fn get<T>(&self) -> AtomicResource<T>where
T: TypedEcsData,
pub fn get<T>(&self) -> AtomicResource<T>where
T: TypedEcsData,
Get a resource handle from the store.
This is not the resource itself, but a handle, may be cloned cheaply.
In order to access the resource you must call borrow() or
borrow_mut() on the returned value.
Panics
Panics if the resource does not exist in the store.
sourcepub fn contains<T>(&self) -> boolwhere
T: TypedEcsData,
pub fn contains<T>(&self) -> boolwhere
T: TypedEcsData,
Check whether or not a resource is in the store.
See get()
sourcepub fn try_get<T>(&self) -> Option<AtomicResource<T>>where
T: TypedEcsData,
pub fn try_get<T>(&self) -> Option<AtomicResource<T>>where
T: TypedEcsData,
Gets a resource handle from the store if it exists.
sourcepub fn untyped(&self) -> &UntypedResources
pub fn untyped(&self) -> &UntypedResources
Borrow the underlying UntypedResources store.
sourcepub fn untyped_mut(&mut self) -> &mut UntypedResources
pub fn untyped_mut(&mut self) -> &mut UntypedResources
Mutably borrow the underlying UntypedResources store.
sourcepub fn into_untyped(self) -> UntypedResources
pub fn into_untyped(self) -> UntypedResources
Consume Resources and extract the underlying UntypedResources.