Struct undo::history::History[][src]

pub struct History<A, F = Box<dyn FnMut(Signal)>> { /* fields omitted */ }
Expand description

A history of actions.

Unlike Record which maintains a linear undo history, History maintains an undo tree containing every edit made to the target.

Examples

let mut target = String::new();
let mut history = History::new();
history.apply(&mut target, Add('a')).unwrap();
history.apply(&mut target, Add('b')).unwrap();
history.apply(&mut target, Add('c')).unwrap();
let abc = history.branch();
history.go_to(&mut target, abc, 1).unwrap().unwrap();
history.apply(&mut target, Add('f')).unwrap();
history.apply(&mut target, Add('g')).unwrap();
assert_eq!(target, "afg");
history.go_to(&mut target, abc, 3).unwrap().unwrap();
assert_eq!(target, "abc");

Implementations

Returns a new history.

Reserves capacity for at least additional more actions.

Panics

Panics if the new capacity overflows usize.

Returns the capacity of the history.

Shrinks the capacity of the history as much as possible.

Returns the number of actions in the current branch of the history.

Returns true if the current branch of the history is empty.

Returns the limit of the history.

Sets how the signal should be handled when the state changes.

The previous slot is returned if it exists.

Removes and returns the slot if it exists.

Returns true if the target is in a saved state, false otherwise.

Returns true if the history can undo.

Returns true if the history can redo.

Returns the current branch.

Returns the position of the current action.

Returns a queue.

Returns a checkpoint.

Returns a structure for configurable formatting of the history.

Pushes the action to the top of the history and executes its apply method.

Errors

If an error occur when executing apply the error is returned.

Calls the undo method for the active action and sets the previous one as the new active one.

Errors

If an error occur when executing undo the error is returned.

Calls the redo method for the active action and sets the next one as the new active one.

Errors

If an error occur when executing redo the error is returned.

Marks the target as currently being in a saved or unsaved state.

Removes all actions from the history without undoing them.

Repeatedly calls undo or redo until the action in branch at current is reached.

Errors

If an error occur when executing undo or redo the error is returned.

Go back or forward in the history to the action that was made closest to the datetime provided.

This method does not jump across branches.

Returns the string of the action which will be undone in the next call to undo.

Returns the string of the action which will be redone in the next call to redo.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.