pub struct ResourceManager { /* private fields */ }Expand description
Central storage of resources used in the game. Accessible from
App by default.
For loading assets, you probably do not want to use this directly. In most cases, Assets should be used instead.
Cloning a ResourceManager will do a shallow copy, meaning copies will
all use the same internal storage. You do not have to and should not wrap
this type in an Rc.
See the module-level documentation for more information.
Implementations§
Source§impl ResourceManager
impl ResourceManager
Sourcepub fn allocate<T>(&self) -> ResourceHandle<T>
pub fn allocate<T>(&self) -> ResourceHandle<T>
Allocates and returns a new ResourceHandle for the given type.
See the module-level documentation for more information.
Sourcepub fn set<T>(&self, handle: ResourceHandle<T>, data: T)
pub fn set<T>(&self, handle: ResourceHandle<T>, data: T)
Sets the underlying value of the given ResourceHandle.
See the module-level documentation for more information.
Sourcepub fn get<T>(&self, handle: ResourceHandle<T>) -> Option<ResourceRef<T>>
pub fn get<T>(&self, handle: ResourceHandle<T>) -> Option<ResourceRef<T>>
Returns a reference to the underlying value of the given
ResourceHandle.
Generally speaking, you should call this function again every time you need to access the data instead of keeping around the returned guard.
§Panics
Panics if there is already a ResourceRef to the same resource.
See the module-level documentation for more information.
Trait Implementations§
Source§impl Clone for ResourceManager
impl Clone for ResourceManager
Source§fn clone(&self) -> ResourceManager
fn clone(&self) -> ResourceManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more