Struct redo::RecordBuilder
[−]
[src]
pub struct RecordBuilder<'a, R, C: Command<R>> { /* fields omitted */ }
Builder for a record.
Methods
impl<'a, R, C: Command<R>> RecordBuilder<'a, R, C>
[src]
pub fn capacity(self, capacity: usize) -> RecordBuilder<'a, R, C>
[src]
Sets the capacity for the record.
pub fn limit(self, limit: usize) -> RecordBuilder<'a, R, C>
[src]
Sets the limit
for the record.
If this limit is reached it will start popping of commands at the beginning of the record when pushing new commands on to the stack. No limit is set by default which means it may grow indefinitely.
Examples
let mut record = Record::builder() .capacity(2) .limit(2) .default(); record.exec(Add('a'))?; record.exec(Add('b'))?; record.exec(Add('c'))?; // 'a' is removed from the record since limit is 2. assert_eq!(record.as_receiver(), "abc"); record.undo().unwrap()?; record.undo().unwrap()?; assert!(record.undo().is_none()); assert_eq!(record.into_receiver(), "a");
pub fn signals<F>(self, f: F) -> RecordBuilder<'a, R, C> where
F: FnMut(Signal) + Send + Sync + 'a,
[src]
F: FnMut(Signal) + Send + Sync + 'a,
Decides how different signals should be handled when the state changes. By default the record does nothing.
Examples
Record::builder() .signals(|signal| { match signal { Signal::Undo(true) => println!("The record can undo."), Signal::Undo(false) => println!("The record can not undo."), Signal::Redo(true) => println!("The record can redo."), Signal::Redo(false) => println!("The record can not redo."), Signal::Saved(true) => println!("The receiver is in a saved state."), Signal::Saved(false) => println!("The receiver is not in a saved state."), Signal::Active { old, new } => { println!("The active command has changed from {} to {}.", old, new); } } }) .default();
pub fn build<T: Into<R>>(self, receiver: T) -> Record<'a, R, C>
[src]
Creates the record.
impl<'a, R: Default, C: Command<R>> RecordBuilder<'a, R, C>
[src]
Trait Implementations
Auto Trait Implementations
impl<'a, R, C> Send for RecordBuilder<'a, R, C> where
C: Send,
R: Send,
C: Send,
R: Send,
impl<'a, R, C> Sync for RecordBuilder<'a, R, C> where
C: Sync,
R: Sync,
C: Sync,
R: Sync,