Struct bo::History

source · []
pub struct History {
    pub operations: VecDeque<Operation>,
    pub last_edit_time: Instant,
}
Expand description

History is a bounded double-ended Vec of Operations. Every-time a new change is registered, it is added to the history. If the time elapsed since the last change is greater than TIME_AFTER_WHICH_OPERATION_COMMITS, a new operation is added to the operations VecDeque. If not, the content of the back (last) operation is mutated in place.

Fields

operations: VecDeque<Operation>last_edit_time: Instant

Implementations

Push (by either creating a new Operation or mutating the last one) an Insert operation in history based on the provided inserted text and position.

Push (by either creating a new Operation or mutating the last one) a Delete operation in history based on the provided deleted text and position.

Register that an insertion of provided text occured at the provided position.

Either register that as a whole new Operation, or mutate the back Operation depending whether the elapsed time since the last operation is greater than TIME_AFTER_WHICH_OPERATION_COMMITS. However, if the back operation was a Delee, push a new Insert Operation in the history.

Register that a deletion of provided text occured at the provided position.

Either register that as a whole new Operation, or mutate the back Operation depending whether the elapsed time since the last operation is greater than TIME_AFTER_WHICH_OPERATION_COMMITS. However, if the back operation was an Insert, push a new Delete Operation in the history.

If any Operation is in the history, pop it and returm its reversed Operation.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.