Struct redo::history::History[][src]

pub struct History<C: Command, F = fn(_: Signal)> { /* fields omitted */ }
Expand description

A history of commands.

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

Examples

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

Implementations

Returns a new history.

Reserves capacity for at least additional more commands.

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 commands 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 command.

Returns a queue.

Returns a checkpoint.

Returns a structure for configurable formatting of the history.

Returns a reference to the target.

Returns a mutable reference to the target.

This method should only be used when doing changes that should not be able to be undone.

Consumes the history, returning the target.

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

Removes all commands from the history without undoing them.

Pushes the command 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 command 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 command and sets the next one as the new active one.

Errors

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

Repeatedly calls undo or redo until the command 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 command that was made closest to the datetime provided.

This method does not jump across branches.

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

Returns the string of the command 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)

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.