Skip to main content

with_cache_dims

Function with_cache_dims 

Source
pub fn with_cache_dims<F, M>(
    policy: CachePolicy,
    source: &str,
    dest: &str,
    key: RenderKey,
    convert: F,
    measure: M,
) -> ConvertResult
where F: FnOnce() -> bool, M: FnOnce() -> Option<CachedDims>,
Expand description

Cache-aware wrapper around any (source, dest) -> bool conversion that also wants to round-trip dimensions through the cache.

measure runs on the freshly-produced dest and feeds the cache for next time. On a cache hit measure is NOT called — the cached .dims value is returned instead.

Callers without a dimension hook can pass measure = || None to get the bytes-only cache behaviour.

policy decides whether the shared cache is consulted at all; see CachePolicy.