pub trait ImageCache: 'static {
// Required method
fn load(
&mut self,
resource: &Resource,
window: &mut Window,
cx: &mut App,
) -> Option<Result<Arc<RenderImage>, ImageCacheError>>;
}Expand description
A store of decoded images that img elements read from.
Implement it to control how images load and when they are released. RetainAllImageCache
keeps every image until you clear it. Release images you no longer need, so they are removed
from all windows.
Required Methods§
Sourcefn load(
&mut self,
resource: &Resource,
window: &mut Window,
cx: &mut App,
) -> Option<Result<Arc<RenderImage>, ImageCacheError>>
fn load( &mut self, resource: &Resource, window: &mut Window, cx: &mut App, ) -> Option<Result<Arc<RenderImage>, ImageCacheError>>
Returns the image for resource if it is ready, or None while it loads.
This runs on every layout and paint of each image that uses the cache, so it must return
quickly. Start the load in the background, return None, and notify the current view when
the load finishes, as RetainAllImageCache does. The element is then drawn again.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".