[][src]Trait undo::Command

pub trait Command<T>: 'static + Debug {
    fn apply(&mut self, target: &mut T) -> Result;
fn undo(&mut self, target: &mut T) -> Result; fn redo(&mut self, target: &mut T) -> Result { ... }
fn merge(&self) -> Merge { ... }
fn text(&self) -> String { ... } }

Base functionality for all commands.

Required methods

fn apply(&mut self, target: &mut T) -> Result

Applies the command on the target and returns Ok if everything went fine, and Err if something went wrong.

fn undo(&mut self, target: &mut T) -> Result

Restores the state of the target as it was before the command was applied and returns Ok if everything went fine, and Err if something went wrong.

Loading content...

Provided methods

fn redo(&mut self, target: &mut T) -> Result

Reapplies the command on the target and return Ok if everything went fine, and Err if something went wrong.

The default implementation uses the apply implementation.

fn merge(&self) -> Merge

Used for automatic merging of commands.

When commands are merged together, undoing and redoing them are done in one step.

fn text(&self) -> String

Returns the text of the command.

Loading content...

Implementors

impl<T, A: Command<T>, B: Command<T>> Command<T> for Join<A, B>[src]

impl<T, C: Command<T>> Command<T> for WithMerge<C>[src]

impl<T, C: Command<T>> Command<T> for WithText<C>[src]

impl<T: Debug + Clone, F: FnMut(&mut T)> Command<T> for FromFn<T, F>[src]

Loading content...