pub trait HistoryCommand: Send + Sync {
// Required methods
fn execute(&mut self) -> CommandResult;
fn undo(&mut self) -> CommandResult;
fn description(&self) -> &str;
// Provided methods
fn redo(&mut self) -> CommandResult { ... }
fn can_merge(&self, _other: &dyn Command) -> bool { ... }
fn merge(&mut self, _other: Box<dyn Command>) -> Option<Box<dyn Command>> { ... }
fn memory_size(&self) -> usize { ... }
fn metadata(&self) -> Option<&(dyn Any + 'static)> { ... }
}Expand description
Trait for undoable commands
Required Methods§
Sourcefn execute(&mut self) -> CommandResult
fn execute(&mut self) -> CommandResult
Execute the command
Sourcefn undo(&mut self) -> CommandResult
fn undo(&mut self) -> CommandResult
Undo the command
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Get command description
Provided Methods§
Sourcefn redo(&mut self) -> CommandResult
fn redo(&mut self) -> CommandResult
Redo the command (default: re-execute)
Sourcefn merge(&mut self, _other: Box<dyn Command>) -> Option<Box<dyn Command>>
fn merge(&mut self, _other: Box<dyn Command>) -> Option<Box<dyn Command>>
Merge with another command (returns merged command)
Sourcefn memory_size(&self) -> usize
fn memory_size(&self) -> usize
Estimate memory usage of this command