pub struct Cache {}Expand description
A interface for managing various game resources.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn load_async(filename: &str, handler: Box<dyn FnMut(bool)>)
pub fn load_async(filename: &str, handler: Box<dyn FnMut(bool)>)
Loads a file into the cache asynchronously.
§Arguments
filenames- The name of the file(s) to load. This can be a single string or a vector of strings.handler- A callback function that is invoked when the file is loaded.
Sourcepub fn update_item(filename: &str, content: &str)
pub fn update_item(filename: &str, content: &str)
Updates the content of a file loaded in the cache. If the item of filename does not exist in the cache, a new file content will be added into the cache.
§Arguments
filename- The name of the file to update.content- The new content for the file.
Sourcepub fn update_texture(filename: &str, texture: &Texture2D)
pub fn update_texture(filename: &str, texture: &Texture2D)
Updates the texture object of the specific filename loaded in the cache. If the texture object of filename does not exist in the cache, it will be added into the cache.
§Arguments
filename- The name of the texture to update.texture- The new texture object for the file.
Sourcepub fn unload_item_or_type(name: &str) -> bool
pub fn unload_item_or_type(name: &str) -> bool
Unloads a resource from the cache.
§Arguments
name- The type name of resource to unload, could be one of “Texture”, “SVG”, “Clip”, “Frame”, “Model”, “Particle”, “Shader”, “Font”, “Sound”, “Spine”. Or the name of the resource file to unload.
§Returns
bool-trueif the resource was unloaded successfully,falseotherwise.
Sourcepub fn remove_unused()
pub fn remove_unused()
Removes all unused resources (not being referenced) from the cache.
Sourcepub fn remove_unused_by_type(type_name: &str)
pub fn remove_unused_by_type(type_name: &str)
Removes all unused resources of the given type from the cache.
§Arguments
resource_type- The type of resource to remove. This could be one of “Texture”, “SVG”, “Clip”, “Frame”, “Model”, “Particle”, “Shader”, “Font”, “Sound”, “Spine”.
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more