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

Method get_or_create_async

src/renderer.rs:345–356  ·  view source on GitHub ↗
(&mut self, key: String, create_fn: F)

Source from the content-addressed store, hash-verified

343 }
344
345 pub async fn get_or_create_async<F, Fut>(&mut self, key: String, create_fn: F) -> &Texture2D
346 where F: FnOnce() -> Fut,
347 Fut: std::future::Future<Output = Texture2D>
348 {
349 if !self.textures.contains_key(&key) {
350 let texture = create_fn().await;
351 self.textures.insert(key.clone(), CacheEntry { frames_not_used: 0, owner: texture.into() });
352 }
353 let entry = self.textures.get_mut(&key).unwrap();
354 entry.frames_not_used = 0;
355 entry.owner.texture()
356 }
357
358 /// Cache a value with the given key. Accepts `Texture2D` or `RenderTarget`.
359 #[allow(private_bounds)]

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.80
textureMethod · 0.80

Tested by

no test coverage detected