pub struct BlockCache { /* private fields */ }Expand description
Cached rendered lines for a block. Stores a version counter so the cache is only recomputed when the block content actually changes.
Fields are private - use invalidate() to mark stale, is_stale() to check,
get() to read cached lines, and store() to populate.
Implementations§
Source§impl BlockCache
impl BlockCache
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Bump the version to invalidate cached lines and height.
Sourcepub fn get(&self) -> Option<&Vec<Line<'static>>>
pub fn get(&self) -> Option<&Vec<Line<'static>>>
Get a reference to the cached lines, if fresh.
Sourcepub fn store(&mut self, lines: Vec<Line<'static>>)
pub fn store(&mut self, lines: Vec<Line<'static>>)
Store freshly rendered lines, marking the cache as clean.
Height is set separately via set_height() after measurement.
Sourcepub fn set_height(&mut self, height: usize, width: u16)
pub fn set_height(&mut self, height: usize, width: u16)
Set the wrapped height for the cached lines at the given width.
Called by the viewport/chat layer after Paragraph::line_count(width).
Separate from store() so height measurement is the viewport’s job.
Trait Implementations§
Source§impl Default for BlockCache
impl Default for BlockCache
Source§fn default() -> BlockCache
fn default() -> BlockCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BlockCache
impl RefUnwindSafe for BlockCache
impl Send for BlockCache
impl Sync for BlockCache
impl Unpin for BlockCache
impl UnsafeUnpin for BlockCache
impl UnwindSafe for BlockCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more