pub struct HistoryManager { /* private fields */ }Expand description
History manager for state machine edits
Maintains undo and redo stacks for state machine modifications. Supports configurable maximum history size to limit memory usage.
Implementations§
Source§impl HistoryManager
impl HistoryManager
Sourcepub fn new() -> HistoryManager
pub fn new() -> HistoryManager
Create a new history manager with default max history (50)
Sourcepub fn with_max_history(max_history: usize) -> HistoryManager
pub fn with_max_history(max_history: usize) -> HistoryManager
Create a new history manager with specified max history
Sourcepub fn push_state(&mut self, state: StateMachine)
pub fn push_state(&mut self, state: StateMachine)
Push a new state to the history
If there’s a current state, it’s moved to the undo stack. The new state becomes the current state.
Sourcepub fn undo(&mut self) -> Option<StateMachine>
pub fn undo(&mut self) -> Option<StateMachine>
Undo the last change
Moves the current state to the redo stack and restores the previous state from the undo stack. Returns the restored state if available.
Sourcepub fn redo(&mut self) -> Option<StateMachine>
pub fn redo(&mut self) -> Option<StateMachine>
Redo the last undone change
Moves the current state to the undo stack and restores the next state from the redo stack. Returns the restored state if available.
Sourcepub fn current(&self) -> Option<&StateMachine>
pub fn current(&self) -> Option<&StateMachine>
Get the current state
Sourcepub fn current_mut(&mut self) -> Option<&mut StateMachine>
pub fn current_mut(&mut self) -> Option<&mut StateMachine>
Get the current state mutably
Sourcepub fn set_current(&mut self, state: StateMachine)
pub fn set_current(&mut self, state: StateMachine)
Set the current state without adding to history
Useful for temporary edits that shouldn’t be tracked.
Sourcepub fn undo_count(&self) -> usize
pub fn undo_count(&self) -> usize
Get the number of undo steps available
Sourcepub fn redo_count(&self) -> usize
pub fn redo_count(&self) -> usize
Get the number of redo steps available
Sourcepub fn max_history(&self) -> usize
pub fn max_history(&self) -> usize
Get the maximum history size
Sourcepub fn set_max_history(&mut self, max_history: usize)
pub fn set_max_history(&mut self, max_history: usize)
Set the maximum history size
If the new max is smaller than current history, older entries are removed.
Trait Implementations§
Source§impl Clone for HistoryManager
impl Clone for HistoryManager
Source§fn clone(&self) -> HistoryManager
fn clone(&self) -> HistoryManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more