pub struct UndoManager<T: SettingsSchema + PartialEq> { /* private fields */ }Expand description
Manages undo/redo history for setting changes.
Wraps a SettingsRepository and automatically records changes
when using UndoManager::set_field instead of SettingsRepository::set_field.
Implementations§
Source§impl<T: SettingsSchema + PartialEq> UndoManager<T>
impl<T: SettingsSchema + PartialEq> UndoManager<T>
pub fn new(repository: Arc<SettingsRepository<T>>, max_history: usize) -> Self
Sourcepub fn set_field(&self, name: &str, value: Value) -> Result<(), SettingsError>
pub fn set_field(&self, name: &str, value: Value) -> Result<(), SettingsError>
Set a field and automatically record the change for undo.
Sourcepub fn record_change(
&self,
field_name: impl Into<String>,
old_value: Value,
new_value: Value,
)
pub fn record_change( &self, field_name: impl Into<String>, old_value: Value, new_value: Value, )
Record a change for undo support (separate call required when using
SettingsRepository::set_field directly).
Sourcepub fn undo(&self) -> Result<bool, SettingsError>
pub fn undo(&self) -> Result<bool, SettingsError>
Undo the last change.
Sourcepub fn redo(&self) -> Result<bool, SettingsError>
pub fn redo(&self) -> Result<bool, SettingsError>
Redo the last undone change.
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
pub fn undo_description(&self) -> Option<String>
pub fn redo_description(&self) -> Option<String>
Sourcepub fn clear_history(&self)
pub fn clear_history(&self)
Clear all undo/redo history.
Auto Trait Implementations§
impl<T> !Freeze for UndoManager<T>
impl<T> !RefUnwindSafe for UndoManager<T>
impl<T> !UnwindSafe for UndoManager<T>
impl<T> Send for UndoManager<T>
impl<T> Sync for UndoManager<T>
impl<T> Unpin for UndoManager<T>
impl<T> UnsafeUnpin for UndoManager<T>
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