Struct undo::record::Record[][src]

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

A record of actions.

The record can roll the targets state backwards and forwards by using the undo and redo methods. In addition, the record can notify the user about changes to the stack or the target through signal. The user can give the record a function that is called each time the state changes by using the builder.

Examples

let mut target = String::new();
let mut record = Record::new();
record.apply(&mut target, Add('a'))?;
record.apply(&mut target, Add('b'))?;
record.apply(&mut target, Add('c'))?;
assert_eq!(target, "abc");
record.undo(&mut target).unwrap()?;
record.undo(&mut target).unwrap()?;
record.undo(&mut target).unwrap()?;
assert_eq!(target, "");
record.redo(&mut target).unwrap()?;
record.redo(&mut target).unwrap()?;
record.redo(&mut target).unwrap()?;
assert_eq!(target, "abc");

Implementations

Returns a new record.

Reserves capacity for at least additional more actions.

Panics

Panics if the new capacity overflows usize.

Returns the capacity of the record.

Shrinks the capacity of the record as much as possible.

Returns the number of actions in the record.

Returns true if the record 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 record can undo.

Returns true if the record can redo.

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

Returns the position of the current action.

Returns a queue.

Returns a checkpoint.

Returns a structure for configurable formatting of the record.

Pushes the action on top of the record 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 record 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.

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.