Change
struct · ferroui-dynamic-data · v0.5.0
struct Change<T, K>
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.
Members
newwith_indexwith_previousupdatemovedkeyreasoncurrentpreviouscurrent_indexprevious_indexinto_parts
new
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).
with_index
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)).
with_previous
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).
update
fn update(key: K, current: T, previous: T) -> Self
An update of key from previous to current (Change(ChangeReason.Update, key, current, previous)).
moved
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)).
key
fn key(self: &Self) -> &K
The key of the item (Key).
reason
fn reason(self: &Self) -> ChangeReason
The reason of the change (Reason).
current
fn current(self: &Self) -> &T
The item (Current).
previous
fn previous(self: &Self) -> Option<&T>
The item that an update replaced (Previous).
current_index
fn current_index(self: &Self) -> Option<usize>
The index of the item in a sorted collection (CurrentIndex; -1 upstream when none).
previous_index
fn previous_index(self: &Self) -> Option<usize>
The previous index of the item (PreviousIndex).
into_parts
fn into_parts(self: Self) -> (ChangeReason, K, T, Option<T>)
The parts of the change, taken apart.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedEquivalent<K>CloneStructuralPartialEqPartialEqEqHashDebugFromIterator<Change<T, K>>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.