pub struct DeltaTracked<T> { /* private fields */ }Expand description
A collection with cursor-based delta tracking.
DeltaTracked<T> wraps a Vec<T> and tracks which items have been
consumed via take_delta(). This provides an efficient way to accumulate
items over time and periodically extract only the new ones.
The cursor marks the position up to which items have been taken.
take_delta() returns items[cursor..] and advances the cursor.
Implementations§
Source§impl<T> DeltaTracked<T>
impl<T> DeltaTracked<T>
Sourcepub fn new(items: Vec<T>) -> Self
pub fn new(items: Vec<T>) -> Self
Create from existing items with cursor at the end (no pending delta).
Sourcepub fn extend(&mut self, iter: impl IntoIterator<Item = T>)
pub fn extend(&mut self, iter: impl IntoIterator<Item = T>)
Append multiple items.
Sourcepub fn into_items(self) -> Vec<T>
pub fn into_items(self) -> Vec<T>
Consume and return the inner Vec<T>.
Sourcepub fn initial_count(&self) -> usize
pub fn initial_count(&self) -> usize
Number of items that existed before any push/extend (the initial set).
Stable across take_delta() calls.
Source§impl<T: Clone> DeltaTracked<T>
impl<T: Clone> DeltaTracked<T>
Sourcepub fn take_delta(&mut self) -> Vec<T>
pub fn take_delta(&mut self) -> Vec<T>
Clone and return items added since the last take_delta(), then advance the cursor.
Trait Implementations§
Source§impl<T: Clone> Clone for DeltaTracked<T>
impl<T: Clone> Clone for DeltaTracked<T>
Source§fn clone(&self) -> DeltaTracked<T>
fn clone(&self) -> DeltaTracked<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for DeltaTracked<T>
impl<T: Debug> Debug for DeltaTracked<T>
Auto Trait Implementations§
impl<T> Freeze for DeltaTracked<T>
impl<T> RefUnwindSafe for DeltaTracked<T>where
T: RefUnwindSafe,
impl<T> Send for DeltaTracked<T>where
T: Send,
impl<T> Sync for DeltaTracked<T>where
T: Sync,
impl<T> Unpin for DeltaTracked<T>where
T: Unpin,
impl<T> UnwindSafe for DeltaTracked<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more