Struct redo::record::Record[][src]

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

A record of commands.

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 record = Record::default();
record.apply(Add('a'))?;
record.apply(Add('b'))?;
record.apply(Add('c'))?;
assert_eq!(record.target(), "abc");
record.undo()?;
record.undo()?;
record.undo()?;
assert_eq!(record.target(), "");
record.redo()?;
record.redo()?;
record.redo()?;
assert_eq!(record.target(), "abc");

Implementations

Returns a new record.

Reserves capacity for at least additional more commands.

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

Returns a queue.

Returns a checkpoint.

Returns a structure for configurable formatting of the record.

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 record, returning the target.

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

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

Removes all commands from the record without undoing them.

Pushes the command 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 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 applying redo the error is returned.

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

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.