MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / get_or_load

Method get_or_load

src/renderer.rs:322–330  ·  view source on GitHub ↗

Get the cached texture by its key, or load from a file path and cache it.

(&mut self, path: &'static str)

Source from the content-addressed store, hash-verified

320
321 /// Get the cached texture by its key, or load from a file path and cache it.
322 pub async fn get_or_load(&mut self, path: &'static str) -> &Texture2D {
323 if !self.textures.contains_key(path) {
324 let texture = load_texture(resolve_asset_path(path)).await.unwrap();
325 self.textures.insert(path.to_owned(), CacheEntry { frames_not_used: 0, owner: texture.into() });
326 }
327 let entry = self.textures.get_mut(path).unwrap();
328 entry.frames_not_used = 0;
329 entry.owner.texture()
330 }
331
332 /// Get the cached texture by its key, or create it using the provided function and cache it.
333 pub fn get_or_create<F>(&mut self, key: String, create_fn: F) -> &Texture2D

Callers 1

renderFunction · 0.80

Calls 2

resolve_asset_pathFunction · 0.85
textureMethod · 0.80

Tested by

no test coverage detected