pub struct LayoutCache { /* private fields */ }Expand description
A memoizing cache of computed layout rectangles.
Implementations§
Source§impl LayoutCache
impl LayoutCache
Sourcepub fn hits(&self) -> u64
pub fn hits(&self) -> u64
Cache hit count since creation (or last reset_stats).
Sourcepub fn misses(&self) -> u64
pub fn misses(&self) -> u64
Cache miss count since creation (or last reset_stats).
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset the hit/miss counters (leaves entries intact).
Sourcepub fn get(
&mut self,
id: WidgetId,
avail: Size,
content_hash: u64,
) -> Option<Rect>
pub fn get( &mut self, id: WidgetId, avail: Size, content_hash: u64, ) -> Option<Rect>
Look up the cached rect for (id, avail, content_hash).
Returns None (a miss) when there is no matching entry or when id
is currently marked dirty. Updates the hit/miss counters.
Sourcepub fn put(&mut self, id: WidgetId, avail: Size, content_hash: u64, rect: Rect)
pub fn put(&mut self, id: WidgetId, avail: Size, content_hash: u64, rect: Rect)
Store the computed rect for (id, avail, content_hash), clearing any
dirty flag on id (it is now freshly computed).
Sourcepub fn invalidate(&mut self, id: WidgetId)
pub fn invalidate(&mut self, id: WidgetId)
Mark id dirty so its next get misses regardless of key.
The stale entries are dropped immediately to bound memory.
Sourcepub fn invalidate_many(&mut self, ids: impl IntoIterator<Item = WidgetId>)
pub fn invalidate_many(&mut self, ids: impl IntoIterator<Item = WidgetId>)
Mark several nodes dirty at once (e.g. an invalidated subtree).
Trait Implementations§
Source§impl Debug for LayoutCache
impl Debug for LayoutCache
Source§impl Default for LayoutCache
impl Default for LayoutCache
Source§fn default() -> LayoutCache
fn default() -> LayoutCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LayoutCache
impl RefUnwindSafe for LayoutCache
impl Send for LayoutCache
impl Sync for LayoutCache
impl Unpin for LayoutCache
impl UnsafeUnpin for LayoutCache
impl UnwindSafe for LayoutCache
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