pub struct UndoEntry<C> { /* private fields */ }Expand description
One reversible unit — a snapshot of a single document state (TR-010).
Restoring an entry reproduces the document at this state: the CST snapshot,
the exact prior buffer bytes (source_text), and the caller’s cursor value
(cursor). Generic over the cursor/metadata type C so ronin-core stays
decoupled from any surface’s cursor representation (see module docs).
§Downstream reuse (E005 / E008 — TR-013)
Downstream editing epics build an entry with new after applying
an edit, then hand it to UndoStack::record. On undo/redo they read back the
snapshot through source_text (write to the buffer
verbatim — exact-prior-byte restore), cst_snapshot
(reuse the structurally-shared tree without re-parsing), and
cursor (restore caret/selection).
Implementations§
Source§impl<C> UndoEntry<C>
impl<C> UndoEntry<C>
Sourcepub fn new(cst_snapshot: CstDocument, source_text: String, cursor: C) -> Self
pub fn new(cst_snapshot: CstDocument, source_text: String, cursor: C) -> Self
Snapshot a document state into a new undo unit.
cst_snapshot should correspond to source_text (the CST whose printout
is those exact bytes); cursor is the surface state to restore alongside.
Sourcepub fn cst_snapshot(&self) -> &CstDocument
pub fn cst_snapshot(&self) -> &CstDocument
The CST snapshot at this state.
Sourcepub fn source_text(&self) -> &str
pub fn source_text(&self) -> &str
The exact prior buffer text this unit restores.
Sourcepub fn byte_size(&self) -> usize
pub fn byte_size(&self) -> usize
The retained byte-size this entry contributes to the stack’s size cap —
the length of the snapshot’s source_text in bytes (TR-024).
The CST snapshot itself is structurally shared and is not counted here; the source text is the dominant, deterministic per-unit cost.