pub struct UndoManager {
document_id: String,
replica_id: String,
clock: u64,
history: Vec<Operation>,
undo_stack: VecDeque<OperationId>,
redo_stack: VecDeque<OperationId>,
current_group: Option<GroupId>,
max_history: usize,
}Expand description
An undo manager for a single document.
Fields§
§document_id: StringThe document ID.
replica_id: StringThe local replica ID.
clock: u64Lamport clock.
history: Vec<Operation>Operation history (all operations, including from other replicas).
undo_stack: VecDeque<OperationId>Undo stack (local operations that can be undone).
redo_stack: VecDeque<OperationId>Redo stack (local operations that can be redone).
current_group: Option<GroupId>Current group being built.
max_history: usizeMaximum history size.
Implementations§
Source§impl UndoManager
impl UndoManager
Sourcepub fn new(
document_id: impl Into<String>,
replica_id: impl Into<String>,
) -> Self
pub fn new( document_id: impl Into<String>, replica_id: impl Into<String>, ) -> Self
Create a new undo manager.
Sourcepub fn set_max_history(&mut self, max: usize)
pub fn set_max_history(&mut self, max: usize)
Set the maximum history size.
Sourcepub fn record(&mut self, operation: UndoableOperation) -> &Operation
pub fn record(&mut self, operation: UndoableOperation) -> &Operation
Record a local operation.
Sourcepub fn record_remote(&mut self, operation: Operation)
pub fn record_remote(&mut self, operation: Operation)
Record a remote operation (from another replica).
Sourcepub fn start_group(&mut self) -> GroupId
pub fn start_group(&mut self) -> GroupId
Start a new operation group.
Sourcepub fn undo(&mut self) -> Vec<UndoableOperation>
pub fn undo(&mut self) -> Vec<UndoableOperation>
Undo the last operation (or group). Returns the inverse operations to apply.
Sourcepub fn redo(&mut self) -> Vec<UndoableOperation>
pub fn redo(&mut self) -> Vec<UndoableOperation>
Redo the last undone operation. Returns the operations to reapply.
Sourcepub fn undo_stack_size(&self) -> usize
pub fn undo_stack_size(&self) -> usize
Get the undo stack size.
Sourcepub fn redo_stack_size(&self) -> usize
pub fn redo_stack_size(&self) -> usize
Get the redo stack size.
Sourcefn trim_history(&mut self)
fn trim_history(&mut self)
Trim history to max size.
Trait Implementations§
Source§impl Clone for UndoManager
impl Clone for UndoManager
Source§fn clone(&self) -> UndoManager
fn clone(&self) -> UndoManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UndoManager
impl RefUnwindSafe for UndoManager
impl Send for UndoManager
impl Sync for UndoManager
impl Unpin for UndoManager
impl UnwindSafe for UndoManager
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