Trait undo::Command
[−]
[src]
pub trait Command<R> { fn redo(&mut self, receiver: &mut R) -> Result<(), Box<Error>>; fn undo(&mut self, receiver: &mut R) -> Result<(), Box<Error>>; fn id(&self) -> Option<u32> { ... } }
Base functionality for all commands.
Required Methods
fn redo(&mut self, receiver: &mut R) -> Result<(), Box<Error>>
Executes the desired command and returns Ok
if everything went fine, and Err
if
something went wrong.
fn undo(&mut self, receiver: &mut R) -> Result<(), Box<Error>>
Restores the state as it was before redo
was called and returns Ok
if everything
went fine, and Err
if something went wrong.
Provided Methods
fn id(&self) -> Option<u32>
Used for automatic merging of Command
s.
Two commands are merged together when a command is pushed, and it has the same id as the top command already on the stack. When commands are merged together, undoing and redoing them are done in one step.