struct TimelineItemDiffMinimizer<'a, S, I> {
store: &'a S,
item_map: HashMap<String, I>,
updated_item_ids: Vec<String>,
}
Expand description
A helper struct to minimize a list of VectorDiff
.
This does not support VectorDiff::Clear
, VectorDiff::Truncate
and
VectorDiff::Reset
as we assume that lists including those cannot be
minimized in an optimal way.
Fields§
§store: &'a S
§item_map: HashMap<String, I>
§updated_item_ids: Vec<String>
Implementations§
Source§impl<'a, S, I> TimelineItemDiffMinimizer<'a, S, I>
impl<'a, S, I> TimelineItemDiffMinimizer<'a, S, I>
Source§impl<S, I> TimelineItemDiffMinimizer<'_, S, I>
impl<S, I> TimelineItemDiffMinimizer<'_, S, I>
Sourcefn load_items(&mut self) -> Vec<String>
fn load_items(&mut self) -> Vec<String>
Load the items from the store.
Returns the list of timeline IDs of the items.
Sourcefn update_or_create_item(&mut self, data: &S::Data) -> String
fn update_or_create_item(&mut self, data: &S::Data) -> String
Update or create an item in the store using the given data.
Returns the timeline ID of the item.
Sourcefn apply_diff_to_items(
&mut self,
item_ids: &[String],
diff_list: Vec<VectorDiff<S::Data>>,
) -> Vec<String>
fn apply_diff_to_items( &mut self, item_ids: &[String], diff_list: Vec<VectorDiff<S::Data>>, ) -> Vec<String>
Apply the given diff to the given items.
Sourcefn item_diff_list(
&self,
old_item_ids: &[String],
new_item_ids: &[String],
) -> Vec<TimelineItemDiff<S::Item>>
fn item_diff_list( &self, old_item_ids: &[String], new_item_ids: &[String], ) -> Vec<TimelineItemDiff<S::Item>>
Compute the list of item diffs between the two given lists.
Uses a diff algorithm to minimize the removals and additions.
Sourcefn apply(self, diff_list: Vec<VectorDiff<S::Data>>)
fn apply(self, diff_list: Vec<VectorDiff<S::Data>>)
Minimize the given diff and apply it to the store.
Auto Trait Implementations§
impl<'a, S, I> Freeze for TimelineItemDiffMinimizer<'a, S, I>
impl<'a, S, I> RefUnwindSafe for TimelineItemDiffMinimizer<'a, S, I>where
S: RefUnwindSafe,
I: RefUnwindSafe,
impl<'a, S, I> Send for TimelineItemDiffMinimizer<'a, S, I>
impl<'a, S, I> Sync for TimelineItemDiffMinimizer<'a, S, I>
impl<'a, S, I> Unpin for TimelineItemDiffMinimizer<'a, S, I>where
I: Unpin,
impl<'a, S, I> UnwindSafe for TimelineItemDiffMinimizer<'a, S, I>where
S: RefUnwindSafe,
I: 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
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more