pub struct RecordBuilder<R> { /* fields omitted */ }
Sets the specified capacity for the record.
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.
let mut record = Record::builder()
.capacity(2)
.limit(2)
.default();
record.apply(Add('a'))?;
record.apply(Add('b'))?;
record.apply(Add('c'))?;
assert_eq!(record.as_receiver(), "abc");
record.undo().unwrap()?;
record.undo().unwrap()?;
assert!(record.undo().is_none());
assert_eq!(record.into_receiver(), "a");
Decides how different signals should be handled when the state changes.
By default the record does nothing.
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::Cursor { old, new } => {
println!("The current command has changed from {} to {}.", old, new);
}
}
})
.default();
Creates the record with a default receiver
.
Formats the value using the given formatter. Read more