[−][src]Struct undo::Checkpoint
A checkpoint wrapper.
Wraps a record or history and gives it checkpoint functionality. This allows the record or history to cancel all changes made since creating the checkpoint.
Examples
let mut record = Record::default(); let mut cp = record.checkpoint(); cp.apply(Add('a'))?; cp.apply(Add('b'))?; cp.apply(Add('c'))?; assert_eq!(cp.target(), "abc"); cp.cancel()?; assert_eq!(record.target(), "");
Implementations
impl<T, '_> Checkpoint<'_, T>
[src]
pub fn apply(&mut self, command: impl Command<T>) -> Result
[src]
Calls the apply
method.
pub fn undo(&mut self) -> Result
[src]
Calls the undo
method.
pub fn redo(&mut self) -> Result
[src]
Calls the redo
method.
pub fn commit(self)
[src]
Commits the changes and consumes the checkpoint.
pub fn cancel(self) -> Result
[src]
Cancels the changes and consumes the checkpoint.
Errors
If an error occur when canceling the changes, the error is returned and the remaining commands are not canceled.
pub fn queue(&mut self) -> Queue<'_, T>
[src]
Returns a queue.
pub fn checkpoint(&mut self) -> Checkpoint<'_, T>
[src]
Returns a checkpoint.
pub fn target(&self) -> &T
[src]
Returns a reference to the target
.
Trait Implementations
impl<'a, T: Debug + 'static> Debug for Checkpoint<'a, T>
[src]
impl<'a, T> From<&'a mut Record<T>> for Checkpoint<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for Checkpoint<'a, T>
impl<'a, T> !Send for Checkpoint<'a, T>
impl<'a, T> !Sync for Checkpoint<'a, T>
impl<'a, T> Unpin for Checkpoint<'a, T>
impl<'a, T> !UnwindSafe for Checkpoint<'a, T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,