Skip to main content

UndoManager

Struct UndoManager 

Source
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>

Source

pub fn new(repository: Arc<SettingsRepository<T>>, max_history: usize) -> Self

Source

pub fn set_field(&self, name: &str, value: Value) -> Result<(), SettingsError>

Set a field and automatically record the change for undo.

Source

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).

Source

pub fn undo(&self) -> Result<bool, SettingsError>

Undo the last change.

Source

pub fn redo(&self) -> Result<bool, SettingsError>

Redo the last undone change.

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn undo_description(&self) -> Option<String>

Source

pub fn redo_description(&self) -> Option<String>

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.