pub struct Change<T, K> { /* private fields */ }Expand description
A change of one item of a cache (Change<TObject, TKey>): its reason, its key, the item and,
for an update, the item it replaced; the indexes for a sorted collection.
Deviation (DEVIATIONS.md, DynamicData): the indexes are Option<usize>, where upstream writes
-1 for no index.
Implementations§
Source§impl<T, K> Change<T, K>
impl<T, K> Change<T, K>
Sourcepub fn new(reason: ChangeReason, key: K, current: T) -> Self
pub fn new(reason: ChangeReason, key: K, current: T) -> Self
A change without a previous item (Change(ChangeReason, TKey, TObject, int index = -1)).
§Panics
For ChangeReason::Update, which needs the previous item (ArgumentException).
Sourcepub fn with_index(
reason: ChangeReason,
key: K,
current: T,
index: Option<usize>,
) -> Self
pub fn with_index( reason: ChangeReason, key: K, current: T, index: Option<usize>, ) -> Self
A change with the index of the item (Change(ChangeReason, TKey, TObject, int index)).
Sourcepub fn with_previous(
reason: ChangeReason,
key: K,
current: T,
previous: Option<T>,
current_index: Option<usize>,
previous_index: Option<usize>,
) -> Self
pub fn with_previous( reason: ChangeReason, key: K, current: T, previous: Option<T>, current_index: Option<usize>, previous_index: Option<usize>, ) -> Self
A change with every part (Change(ChangeReason, TKey, TObject, in Optional<TObject>, int, int)).
§Panics
For ChangeReason::Add with a previous item, and for ChangeReason::Update without one
(ArgumentException).
Sourcepub fn update(key: K, current: T, previous: T) -> Self
pub fn update(key: K, current: T, previous: T) -> Self
An update of key from previous to current (Change(ChangeReason.Update, key, current, previous)).
Sourcepub fn moved(
key: K,
current: T,
current_index: usize,
previous_index: usize,
) -> Self
pub fn moved( key: K, current: T, current_index: usize, previous_index: usize, ) -> Self
A move within a sorted collection (Change(TKey, TObject, int currentIndex, int previousIndex)).
Sourcepub fn reason(&self) -> ChangeReason
pub fn reason(&self) -> ChangeReason
The reason of the change (Reason).
Sourcepub fn current_index(&self) -> Option<usize>
pub fn current_index(&self) -> Option<usize>
The index of the item in a sorted collection (CurrentIndex; -1 upstream when none).
Sourcepub fn previous_index(&self) -> Option<usize>
pub fn previous_index(&self) -> Option<usize>
The previous index of the item (PreviousIndex).
Sourcepub fn into_parts(self) -> (ChangeReason, K, T, Option<T>)
pub fn into_parts(self) -> (ChangeReason, K, T, Option<T>)
The parts of the change, taken apart.