HistoryCommand

Trait HistoryCommand 

Source
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§

Source

fn execute(&mut self) -> CommandResult

Execute the command

Source

fn undo(&mut self) -> CommandResult

Undo the command

Source

fn description(&self) -> &str

Get command description

Provided Methods§

Source

fn redo(&mut self) -> CommandResult

Redo the command (default: re-execute)

Source

fn can_merge(&self, _other: &dyn Command) -> bool

Check if command can be merged with another

Source

fn merge(&mut self, _other: Box<dyn Command>) -> Option<Box<dyn Command>>

Merge with another command (returns merged command)

Source

fn memory_size(&self) -> usize

Estimate memory usage of this command

Source

fn metadata(&self) -> Option<&(dyn Any + 'static)>

Get command metadata

Implementors§

Source§

impl<T> Command for SetValueCommand<T>
where T: Clone + Send + Sync + 'static,