Crate undo

source ·
Expand description

An undo-redo library.

It is an implementation of the command pattern, where all modifications are done by creating objects that applies the modifications. All objects knows how to undo the changes it applies, and by using the provided data structures it is easy to apply, undo, and redo changes made to a target.

Features

  • Action provides the base functionality for all actions. Multiple Actions can be merged into a single action by implementing the merge method on the action. This allows smaller actions to be used to build more complex operations, or smaller incremental changes to be merged into larger changes that can be undone and redone in a single step.
  • Record provides basic stack based undo-redo functionality.
  • History provides full tree based undo-redo functionality.
  • Queue and checkpoint functionality is supported for both Record and History.
  • The target can be marked as saved to disk and the user will be notified when it changes.
  • The amount of changes being tracked can be configured by the user so only the N most recent changes are stored.
  • Configurable display formatting using the display structures.

Cargo Feature Flags

NameDefaultDescription
coloredEnables colored output when visualizing the display structures.
serdeEnables serialization and deserialization.

Re-exports

Modules

  • A history tree of actions.
  • A linear record of actions.

Structs

  • Any action type.
  • Action made from a function.
  • Two actions joined together.
  • Default slot that does nothing.
  • Action made from a fallible function.
  • Joins two fallible actions together.

Enums

  • Says if the action have been merged with another action.
  • The signal used for communicating state changes.

Traits