Struct undo::timeline::Timeline[][src]

pub struct Timeline<A, F, const LIMIT: usize> { /* fields omitted */ }
Expand description

A timeline of actions.

A timeline works mostly like a record but stores a fixed number of actions on the stack.

Can be used without the alloc feature.

Examples

let mut target = String::new();
let mut timeline = Timeline::<_, _, 32>::new();
timeline.apply(&mut target, Add('a'))?;
timeline.apply(&mut target, Add('b'))?;
timeline.apply(&mut target, Add('c'))?;
assert_eq!(target, "abc");
timeline.undo(&mut target).unwrap()?;
timeline.undo(&mut target).unwrap()?;
timeline.undo(&mut target).unwrap()?;
assert_eq!(target, "");
timeline.redo(&mut target).unwrap()?;
timeline.redo(&mut target).unwrap()?;
timeline.redo(&mut target).unwrap()?;
assert_eq!(target, "abc");

Implementations

Returns a new timeline.

Returns the number of actions in the timeline.

Returns true if the timeline is empty.

Returns the limit of the record.

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 timeline can undo.

Returns true if the timeline can redo.

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

Returns the position of the current action.

Returns a structure for configurable formatting of the record.

Pushes the action on top of the timeline 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 applying redo the error is returned.

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

Removes all actions from the timeline without undoing them.

Revert the changes done to the target since the saved state.

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

Errors

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

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

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.

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.