pub struct TextureManager {
pub max_frames_not_used: usize,
/* private fields */
}Expand description
Manages textures, loading and unloading them as needed. No manual management needed.
You can adjust max_frames_not_used to control how many frames a texture can go unused before being unloaded.
Fields§
§max_frames_not_used: usizeImplementations§
Source§impl TextureManager
impl TextureManager
pub fn new() -> Self
Sourcepub async fn get_or_load(&mut self, path: &'static str) -> &Texture2D
pub async fn get_or_load(&mut self, path: &'static str) -> &Texture2D
Get the cached texture by its key, or load from a file path and cache it.
Sourcepub fn get_or_create<F>(&mut self, key: String, create_fn: F) -> &Texture2D
pub fn get_or_create<F>(&mut self, key: String, create_fn: F) -> &Texture2D
Get the cached texture by its key, or create it using the provided function and cache it.
pub async fn get_or_create_async<F, Fut>( &mut self, key: String, create_fn: F, ) -> &Texture2D
Sourcepub fn cache(
&mut self,
key: String,
value: impl Into<TextureOwner>,
) -> &Texture2D
pub fn cache( &mut self, key: String, value: impl Into<TextureOwner>, ) -> &Texture2D
Cache a value with the given key. Accepts Texture2D or RenderTarget.
pub fn clean(&mut self)
pub fn size(&self) -> usize
Auto Trait Implementations§
impl Freeze for TextureManager
impl RefUnwindSafe for TextureManager
impl Send for TextureManager
impl Sync for TextureManager
impl Unpin for TextureManager
impl UnsafeUnpin for TextureManager
impl UnwindSafe for TextureManager
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