pub struct GlyphCache { /* private fields */ }Expand description
Byte-weighted render output cache
Uses byte-weighted eviction (not entry count) to prevent memory explosions.
Default limit is 512 MB, configurable via TYPF_CACHE_MAX_BYTES.
Implementations§
Source§impl GlyphCache
impl GlyphCache
Sourcepub fn with_max_bytes(max_bytes: u64) -> Self
pub fn with_max_bytes(max_bytes: u64) -> Self
Create a cache with a specific byte limit.
Sourcepub fn get(&self, key: &GlyphCacheKey) -> Option<RenderOutput>
pub fn get(&self, key: &GlyphCacheKey) -> Option<RenderOutput>
Get a cached render output.
Returns None if not found or if caching is globally disabled.
Sourcepub fn insert(&self, key: GlyphCacheKey, output: RenderOutput)
pub fn insert(&self, key: GlyphCacheKey, output: RenderOutput)
Insert a render output into the cache.
Does nothing if caching is globally disabled. Large outputs may be evicted sooner due to byte-weighted eviction.
pub fn hit_rate(&self) -> f64
pub fn metrics(&self) -> CacheMetrics
Sourcepub fn weighted_size(&self) -> u64
pub fn weighted_size(&self) -> u64
Current weighted size in bytes.
Sourcepub fn entry_count(&self) -> u64
pub fn entry_count(&self) -> u64
Number of entries in cache.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GlyphCache
impl !RefUnwindSafe for GlyphCache
impl Send for GlyphCache
impl Sync for GlyphCache
impl Unpin for GlyphCache
impl UnsafeUnpin for GlyphCache
impl !UnwindSafe for GlyphCache
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