zng_ext_image

Trait ImageCacheProxy

source
pub trait ImageCacheProxy: Send + Sync {
    // Provided methods
    fn get(
        &mut self,
        key: &ImageHash,
        source: &ImageSource,
        mode: ImageCacheMode,
        downscale: Option<ImageDownscale>,
        mask: Option<ImageMaskMode>,
    ) -> ProxyGetResult { ... }
    fn data(
        &mut self,
        key: &ImageHash,
        data: &[u8],
        image_format: &ImageDataFormat,
        mode: ImageCacheMode,
        downscale: Option<ImageDownscale>,
        mask: Option<ImageMaskMode>,
        is_loaded: bool,
    ) -> Option<ImageVar> { ... }
    fn remove(&mut self, key: &ImageHash, purge: bool) -> ProxyRemoveResult { ... }
    fn clear(&mut self, purge: bool) { ... }
    fn is_data_proxy(&self) -> bool { ... }
}
Expand description

A custom proxy in IMAGES.

Implementers can intercept cache requests and redirect to another cache request or returns an image directly.

The methods on this API are synchronous, implementers that do any potential slow processing must output a loading ImageVar immediately and update it with the finished pixels when ready.

Provided Methods§

source

fn get( &mut self, key: &ImageHash, source: &ImageSource, mode: ImageCacheMode, downscale: Option<ImageDownscale>, mask: Option<ImageMaskMode>, ) -> ProxyGetResult

Intercept a get request.

source

fn data( &mut self, key: &ImageHash, data: &[u8], image_format: &ImageDataFormat, mode: ImageCacheMode, downscale: Option<ImageDownscale>, mask: Option<ImageMaskMode>, is_loaded: bool, ) -> Option<ImageVar>

Intercept a Data or Static request.

If is_data_proxy also intercept the Read or Download data.

If is_loaded is true the data was read or downloaded and the return var will be bound to an existing var that may already be cached. If it is false the data was already loaded on the source and the return var will be returned directly, without caching.

source

fn remove(&mut self, key: &ImageHash, purge: bool) -> ProxyRemoveResult

Intercept a remove request.

source

fn clear(&mut self, purge: bool)

Called when the cache is cleaned or purged.

source

fn is_data_proxy(&self) -> bool

If this proxy only handles Data and Static sources.

When this is true the get call is delayed to after Read and Download have loaded the data and is skipped for Render and Image.

This is false by default.

Implementors§