pub struct IncrementalBreaker { /* private fields */ }Expand description
Incremental Knuth-Plass line-break optimizer with paragraph-level caching.
Maintains cached break solutions per paragraph and only recomputes paragraphs that have been modified or whose line width has changed.
Implementations§
Source§impl IncrementalBreaker
impl IncrementalBreaker
Sourcepub fn new(width: usize, objective: ParagraphObjective) -> Self
pub fn new(width: usize, objective: ParagraphObjective) -> Self
Create a new incremental breaker with the given line width and objective.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Current generation.
Sourcepub fn objective(&self) -> &ParagraphObjective
pub fn objective(&self) -> &ParagraphObjective
Current paragraph objective.
Sourcepub fn set_width(&mut self, width: usize)
pub fn set_width(&mut self, width: usize)
Update the target line width.
All cached solutions are invalidated (width change affects every paragraph).
Sourcepub fn set_objective(&mut self, objective: ParagraphObjective)
pub fn set_objective(&mut self, objective: ParagraphObjective)
Update the paragraph objective.
All cached solutions are invalidated.
Sourcepub fn invalidate_all(&mut self)
pub fn invalidate_all(&mut self)
Invalidate all cached solutions, forcing full recomputation on next reflow.
Sourcepub fn invalidate_paragraph(&mut self, paragraph_idx: usize)
pub fn invalidate_paragraph(&mut self, paragraph_idx: usize)
Invalidate a specific paragraph by index.
Safe to call with out-of-bounds index (no-op).
Sourcepub fn notify_edit(&mut self, old_text: &str, event: &EditEvent)
pub fn notify_edit(&mut self, old_text: &str, event: &EditEvent)
Notify the breaker of a text edit.
This determines which paragraph(s) are affected by the edit and invalidates their cached solutions. The caller must provide the old text so the breaker can locate paragraph boundaries.
Sourcepub fn reflow(&mut self, text: &str) -> ReflowResult
pub fn reflow(&mut self, text: &str) -> ReflowResult
Reflow the document text, reusing cached solutions where possible.
This is the primary entry point. It splits the text into paragraphs, checks each against cached solutions, and only recomputes dirty ones.
Sourcepub fn reflow_full(&mut self, text: &str) -> ReflowResult
pub fn reflow_full(&mut self, text: &str) -> ReflowResult
Reflow with forced full recomputation (no caching).
Sourcepub fn snapshot(&self) -> BreakerSnapshot
pub fn snapshot(&self) -> BreakerSnapshot
Diagnostic snapshot of the current state.
Trait Implementations§
Source§impl Clone for IncrementalBreaker
impl Clone for IncrementalBreaker
Source§fn clone(&self) -> IncrementalBreaker
fn clone(&self) -> IncrementalBreaker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more