[−][src]Struct redo::Queue
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.as_target(), ""); queue.commit()?; assert_eq!(record.as_target(), "abc");
Methods
impl<'a, T, C> Queue<'a, T, C>
[src]
pub fn new(inner: &'a mut T) -> Queue<'a, T, C>
[src]
Returns a queue.
pub fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
more commands in the queue.
Panics
Panics if the new capacity overflows usize.
pub fn capacity(&self) -> usize
[src]
Returns the capacity of the queue.
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity of the queue as much as possible.
pub fn len(&self) -> usize
[src]
Returns the number of commands in the queue.
pub fn is_empty(&self) -> bool
[src]
Returns true
if the queue is empty.
pub fn apply(&mut self, command: C)
[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 cancel(self)
[src]
Cancels the queued actions.
impl<'_, C: Command, F: FnMut(Signal)> Queue<'_, Record<C, F>, C>
[src]
pub fn go_to(&mut self, current: usize)
[src]
Queues a go_to
action.
pub fn commit(self) -> Result<C>
[src]
Applies the actions that is queued.
Errors
If an error occurs, it stops applying the actions and returns the error.
pub fn checkpoint(&mut self) -> Checkpoint<Record<C, F>, C>
[src]
Returns a checkpoint.
pub fn queue(&mut self) -> Queue<Record<C, F>, C>
[src]
Returns a queue.
pub fn as_target(&self) -> &C::Target
[src]
Returns a reference to the target
.
pub fn as_mut_target(&mut self) -> &mut C::Target
[src]
Returns a mutable reference to the target
.
This method should only be used when doing changes that should not be able to be undone.
impl<'_, C: Command, F: FnMut(Signal)> Queue<'_, History<C, F>, C>
[src]
pub fn go_to(&mut self, branch: usize, current: usize)
[src]
Queues a go_to
action.
pub fn commit(self) -> Result<C>
[src]
Applies the actions that is queued.
Errors
If an error occurs, it stops applying the actions and returns the error.
pub fn checkpoint(&mut self) -> Checkpoint<History<C, F>, C>
[src]
Returns a checkpoint.
pub fn queue(&mut self) -> Queue<History<C, F>, C>
[src]
Returns a queue.
pub fn as_target(&self) -> &C::Target
[src]
Returns a reference to the target
.
pub fn as_mut_target(&mut self) -> &mut C::Target
[src]
Returns a mutable reference to the target
.
This method should only be used when doing changes that should not be able to be undone.
Trait Implementations
impl<'a, T, C> From<&'a mut T> for Queue<'a, T, C>
[src]
impl<'a, T: Debug, C: Debug> Debug for Queue<'a, T, C>
[src]
impl<'a, T: PartialEq, C: PartialEq> PartialEq<Queue<'a, T, C>> for Queue<'a, T, C>
[src]
fn eq(&self, other: &Queue<'a, T, C>) -> bool
[src]
fn ne(&self, other: &Queue<'a, T, C>) -> bool
[src]
impl<'a, T: Eq, C: Eq> Eq for Queue<'a, T, C>
[src]
impl<'a, T: Ord, C: Ord> Ord for Queue<'a, T, C>
[src]
fn cmp(&self, other: &Queue<'a, T, C>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a, T: PartialOrd, C: PartialOrd> PartialOrd<Queue<'a, T, C>> for Queue<'a, T, C>
[src]
fn partial_cmp(&self, other: &Queue<'a, T, C>) -> Option<Ordering>
[src]
fn lt(&self, other: &Queue<'a, T, C>) -> bool
[src]
fn le(&self, other: &Queue<'a, T, C>) -> bool
[src]
fn gt(&self, other: &Queue<'a, T, C>) -> bool
[src]
fn ge(&self, other: &Queue<'a, T, C>) -> bool
[src]
impl<'a, T: Hash, C: Hash> Hash for Queue<'a, T, C>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, T, C> StructuralPartialEq for Queue<'a, T, C>
[src]
impl<'a, T, C> StructuralEq for Queue<'a, T, C>
[src]
impl<'_, T, C> Extend<C> for Queue<'_, T, C>
[src]
fn extend<I: IntoIterator<Item = C>>(&mut self, commands: I)
[src]
impl<'_, C: Command, F> AsRef<<C as Command>::Target> for Queue<'_, Record<C, F>, C>
[src]
impl<'_, C: Command, F> AsRef<<C as Command>::Target> for Queue<'_, History<C, F>, C>
[src]
impl<'_, C: Command, F> AsMut<<C as Command>::Target> for Queue<'_, Record<C, F>, C>
[src]
impl<'_, C: Command, F> AsMut<<C as Command>::Target> for Queue<'_, History<C, F>, C>
[src]
Auto Trait Implementations
impl<'a, T, C> Unpin for Queue<'a, T, C> where
C: Unpin,
C: Unpin,
impl<'a, T, C> Send for Queue<'a, T, C> where
C: Send,
T: Send,
C: Send,
T: Send,
impl<'a, T, C> Sync for Queue<'a, T, C> where
C: Sync,
T: Sync,
C: Sync,
T: Sync,
impl<'a, T, C> !UnwindSafe for Queue<'a, T, C>
impl<'a, T, C> RefUnwindSafe for Queue<'a, T, C> where
C: RefUnwindSafe,
T: RefUnwindSafe,
C: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
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> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,