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
sourceimpl History
impl History
fn set_last_edit_time_to_now(&mut self)
fn push(
&mut self,
text: &str,
position: Position,
operation_type: OperationType
)
sourcefn push_insert(&mut self, text: &str, position: Position)
fn push_insert(&mut self, text: &str, position: Position)
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.
sourcefn push_delete(&mut self, text: &str, position: Position)
fn push_delete(&mut self, text: &str, position: 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.
sourcepub fn register_insertion(&mut self, text: &str, position: Position)
pub fn register_insertion(&mut self, text: &str, position: 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.
sourcepub fn register_deletion(&mut self, text: &str, position: Position)
pub fn register_deletion(&mut self, text: &str, position: Position)
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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for History
impl Send for History
impl Sync for History
impl Unpin for History
impl UnwindSafe for History
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more