Trait redo::Command
[−]
[src]
pub trait Command<R> { type Err; fn redo(&mut self, receiver: &mut R) -> Result<(), Self::Err>; fn undo(&mut self, receiver: &mut R) -> Result<(), Self::Err>; fn merge(&mut self, _: &Self) -> Option<Result<(), Self::Err>> { ... } }
Base functionality for all commands.
Associated Types
type Err
The error type.
Required Methods
fn redo(&mut self, receiver: &mut R) -> Result<(), Self::Err>
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<(), Self::Err>
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 merge(&mut self, _: &Self) -> Option<Result<(), Self::Err>>
Used for manual merging of two Command
s.
Returns Some(Ok)
if the merging was successful, Some(Err)
if something went wrong when
trying to merge, and None
if it did not try to merge.
This method is called with self
being the top command and cmd
being the
new command. If None
is returned from this method, cmd
will be pushed
as normal. However, if the return value is Some(x)
it will not push the command on to
the stack since either it was merged or an error has occurred, and then the stack returns
the x
value.