[][src]Struct undo::Queue

pub struct Queue<'a, T: 'static> { /* fields omitted */ }

A command queue wrapper.

Wraps a record or history and gives it batch queue functionality. This allows the record or history to queue up commands and either cancel or apply them later.

Examples

let mut record = Record::default();
let mut queue = record.queue();
queue.apply(Add('a'));
queue.apply(Add('b'));
queue.apply(Add('c'));
assert_eq!(queue.target(), "");
queue.commit()?;
assert_eq!(record.target(), "abc");

Implementations

impl<'a, T> Queue<'a, T>[src]

pub fn apply(&mut self, command: impl Command<T>)[src]

Queues an apply action.

pub fn undo(&mut self)[src]

Queues an undo action.

pub fn redo(&mut self)[src]

Queues a redo action.

pub fn commit(self) -> Result[src]

Applies the actions that is queued.

Errors

If an error occurs, it stops applying the actions and returns the error.

pub fn cancel(self)[src]

Cancels the queued actions.

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 Queue<'a, T>[src]

impl<'a, T> From<&'a mut Record<T>> for Queue<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for Queue<'a, T>

impl<'a, T> !Send for Queue<'a, T>

impl<'a, T> !Sync for Queue<'a, T>

impl<'a, T> Unpin for Queue<'a, T>

impl<'a, T> !UnwindSafe for Queue<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.