pub struct IncrementalMarkdown { /* private fields */ }Expand description
Paragraph-level incremental markdown cache.
During streaming, text arrives in small chunks appended to a growing block.
Instead of re-parsing the entire block every frame, we split on paragraph
boundaries (\n\n outside code fences) and cache rendered lines for each
completed paragraph. Only the in-progress tail paragraph gets re-rendered.
Implementations§
Source§impl IncrementalMarkdown
impl IncrementalMarkdown
Sourcepub fn from_complete(text: &str) -> Self
pub fn from_complete(text: &str) -> Self
Create from existing full text (e.g. user messages, connection errors). Treats the entire text as a single completed paragraph.
Sourcepub fn append(&mut self, chunk: &str)
pub fn append(&mut self, chunk: &str)
Append a streaming text chunk. Splits completed paragraphs off the tail.
Sourcepub fn lines(
&mut self,
render_fn: &impl Fn(&str) -> Vec<Line<'static>>,
) -> Vec<Line<'static>>
pub fn lines( &mut self, render_fn: &impl Fn(&str) -> Vec<Line<'static>>, ) -> Vec<Line<'static>>
Render all lines: cached paragraphs + fresh tail.
render_fn converts a markdown source string into Vec<Line>.
Lazily renders any paragraph whose cache is still empty.
Sourcepub fn invalidate_renders(&mut self)
pub fn invalidate_renders(&mut self)
Clear all cached paragraph renders (e.g. after toggle collapse). Source text is preserved; re-rendering will rebuild caches.
Trait Implementations§
Source§impl Default for IncrementalMarkdown
impl Default for IncrementalMarkdown
Source§fn default() -> IncrementalMarkdown
fn default() -> IncrementalMarkdown
Auto Trait Implementations§
impl Freeze for IncrementalMarkdown
impl RefUnwindSafe for IncrementalMarkdown
impl Send for IncrementalMarkdown
impl Sync for IncrementalMarkdown
impl Unpin for IncrementalMarkdown
impl UnsafeUnpin for IncrementalMarkdown
impl UnwindSafe for IncrementalMarkdown
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
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>
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>
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