mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 21:52:30 -04:00
chore(sdk): Rename ReattachItems and ReattachItemsDone.
This patch renames `ReattachItems` to `StartReattachItems` and `ReattachItemsDone` to `EndReattachItems`. This naming conveys better the idea of a _state transition_.
This commit is contained in:
@@ -117,7 +117,7 @@ impl UpdateToVectorDiff {
|
||||
/// * [`Update::DetachLastItems`] is decreasing the length of the
|
||||
/// appropriate pair by the number of items to be detached; no
|
||||
/// [`VectorDiff`] is emitted,
|
||||
/// * [`Update::ReattachItems`] and [`Update::ReattachItemsDone`] are
|
||||
/// * [`Update::StartReattachItems`] and [`Update::EndReattachItems`] are
|
||||
/// respectively muting or unmuting the emission of [`VectorDiff`] by
|
||||
/// [`Update::PushItems`].
|
||||
///
|
||||
@@ -203,7 +203,7 @@ impl UpdateToVectorDiff {
|
||||
// Step 3, reattaching detached items:
|
||||
//
|
||||
// ```
|
||||
// Update::ReattachItems
|
||||
// Update::StartReattachItems
|
||||
// Update::PushItems {
|
||||
// position_hint: Position(ChunkIdentifier(2), 2),
|
||||
// items: vec!['b']
|
||||
@@ -217,7 +217,7 @@ impl UpdateToVectorDiff {
|
||||
// position_hint: Position(ChunkIdentifier(3), 0),
|
||||
// items: vec!['c'],
|
||||
// }
|
||||
// Update::ReattachItemsDone
|
||||
// Update::EndReattachItems
|
||||
// ```
|
||||
//
|
||||
// To ensure an optimised behaviour of this algorithm:
|
||||
@@ -225,8 +225,8 @@ impl UpdateToVectorDiff {
|
||||
// * `Update::DetachLastItems` must not emit `VectorDiff::Remove`,
|
||||
//
|
||||
// * `Update::PushItems` must not emit `VectorDiff::Insert`s or
|
||||
// `VectorDiff::Append`s if it happens after `ReattachItems` and before
|
||||
// `ReattachItemsDone`. However, `Self::chunks` must always be updated.
|
||||
// `VectorDiff::Append`s if it happens after `StartReattachItems` and before
|
||||
// `EndReattachItems`. However, `Self::chunks` must always be updated.
|
||||
//
|
||||
// From the `VectorDiff` “point of view”, this optimisation aims at avoiding
|
||||
// removing items to push them again later.
|
||||
@@ -369,12 +369,12 @@ impl UpdateToVectorDiff {
|
||||
*length = new_length;
|
||||
}
|
||||
|
||||
Update::ReattachItems => {
|
||||
Update::StartReattachItems => {
|
||||
// Entering the `reattaching` mode.
|
||||
mute_push_items = true;
|
||||
}
|
||||
|
||||
Update::ReattachItemsDone => {
|
||||
Update::EndReattachItems => {
|
||||
// Exiting the `reattaching` mode.
|
||||
mute_push_items = false;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ impl<const CAP: usize, Item, Gap> LinkedChunk<CAP, Item, Gap> {
|
||||
.push_items(items, &self.chunk_identifier_generator, &mut self.updates);
|
||||
|
||||
if let Some(updates) = self.updates.as_mut() {
|
||||
updates.push(Update::ReattachItems);
|
||||
updates.push(Update::StartReattachItems);
|
||||
}
|
||||
|
||||
let chunk = chunk
|
||||
@@ -376,7 +376,7 @@ impl<const CAP: usize, Item, Gap> LinkedChunk<CAP, Item, Gap> {
|
||||
);
|
||||
|
||||
if let Some(updates) = self.updates.as_mut() {
|
||||
updates.push(Update::ReattachItemsDone);
|
||||
updates.push(Update::EndReattachItems);
|
||||
}
|
||||
|
||||
chunk
|
||||
@@ -469,7 +469,7 @@ impl<const CAP: usize, Item, Gap> LinkedChunk<CAP, Item, Gap> {
|
||||
);
|
||||
|
||||
if let Some(updates) = self.updates.as_mut() {
|
||||
updates.push(Update::ReattachItems);
|
||||
updates.push(Update::StartReattachItems);
|
||||
}
|
||||
|
||||
let chunk = chunk
|
||||
@@ -486,7 +486,7 @@ impl<const CAP: usize, Item, Gap> LinkedChunk<CAP, Item, Gap> {
|
||||
);
|
||||
|
||||
if let Some(updates) = self.updates.as_mut() {
|
||||
updates.push(Update::ReattachItemsDone);
|
||||
updates.push(Update::EndReattachItems);
|
||||
}
|
||||
|
||||
chunk
|
||||
@@ -1721,7 +1721,7 @@ mod tests {
|
||||
position_hint: Position(ChunkIdentifier(2), 0),
|
||||
items: vec!['y', 'z']
|
||||
},
|
||||
ReattachItems,
|
||||
StartReattachItems,
|
||||
PushItems { position_hint: Position(ChunkIdentifier(2), 2), items: vec!['e'] },
|
||||
NewItemsChunk {
|
||||
previous: Some(ChunkIdentifier(2)),
|
||||
@@ -1729,7 +1729,7 @@ mod tests {
|
||||
next: None,
|
||||
},
|
||||
PushItems { position_hint: Position(ChunkIdentifier(3), 0), items: vec!['f'] },
|
||||
ReattachItemsDone,
|
||||
EndReattachItems,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1758,7 +1758,7 @@ mod tests {
|
||||
next: Some(ChunkIdentifier(1)),
|
||||
},
|
||||
PushItems { position_hint: Position(ChunkIdentifier(4), 0), items: vec!['o'] },
|
||||
ReattachItems,
|
||||
StartReattachItems,
|
||||
PushItems {
|
||||
position_hint: Position(ChunkIdentifier(4), 1),
|
||||
items: vec!['a', 'b']
|
||||
@@ -1769,7 +1769,7 @@ mod tests {
|
||||
next: Some(ChunkIdentifier(1)),
|
||||
},
|
||||
PushItems { position_hint: Position(ChunkIdentifier(5), 0), items: vec!['c'] },
|
||||
ReattachItemsDone,
|
||||
EndReattachItems,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1792,9 +1792,9 @@ mod tests {
|
||||
position_hint: Position(ChunkIdentifier(5), 0),
|
||||
items: vec!['r', 's']
|
||||
},
|
||||
ReattachItems,
|
||||
StartReattachItems,
|
||||
PushItems { position_hint: Position(ChunkIdentifier(5), 2), items: vec!['c'] },
|
||||
ReattachItemsDone,
|
||||
EndReattachItems,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1909,7 +1909,7 @@ mod tests {
|
||||
next: Some(ChunkIdentifier(1)),
|
||||
gap: (),
|
||||
},
|
||||
ReattachItems,
|
||||
StartReattachItems,
|
||||
NewItemsChunk {
|
||||
previous: Some(ChunkIdentifier(2)),
|
||||
new: ChunkIdentifier(3),
|
||||
@@ -1919,7 +1919,7 @@ mod tests {
|
||||
position_hint: Position(ChunkIdentifier(3), 0),
|
||||
items: vec!['b', 'c']
|
||||
},
|
||||
ReattachItemsDone,
|
||||
EndReattachItems,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1941,14 +1941,14 @@ mod tests {
|
||||
next: Some(ChunkIdentifier(2)),
|
||||
gap: (),
|
||||
},
|
||||
ReattachItems,
|
||||
StartReattachItems,
|
||||
NewItemsChunk {
|
||||
previous: Some(ChunkIdentifier(4)),
|
||||
new: ChunkIdentifier(5),
|
||||
next: Some(ChunkIdentifier(2)),
|
||||
},
|
||||
PushItems { position_hint: Position(ChunkIdentifier(5), 0), items: vec!['a'] },
|
||||
ReattachItemsDone,
|
||||
EndReattachItems,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ pub enum Update<Item, Gap> {
|
||||
/// This value is given to prevent the need for position computations by
|
||||
/// the update readers. Items are pushed, so the positions should be
|
||||
/// incrementally computed from the previous items, which requires the
|
||||
/// reading of the last previous item. With `position_hint`, the update
|
||||
/// readers no longer need to do so.
|
||||
/// reading of the last previous item. With `at`, the update readers no
|
||||
/// longer need to do so.
|
||||
position_hint: Position,
|
||||
|
||||
/// The items.
|
||||
@@ -85,11 +85,11 @@ pub enum Update<Item, Gap> {
|
||||
at: Position,
|
||||
},
|
||||
|
||||
/// Detached items (see [`Self::DetachLastItems`]) are being reattached.
|
||||
ReattachItems,
|
||||
/// Detached items (see [`Self::DetachLastItems`]) starts being reattached.
|
||||
StartReattachItems,
|
||||
|
||||
/// Reattaching items (see [`Self::ReattachItems`]) is finished.
|
||||
ReattachItemsDone,
|
||||
/// Reattaching items (see [`Self::StartReattachItems`]) is finished.
|
||||
EndReattachItems,
|
||||
}
|
||||
|
||||
impl<Item, Gap> Clone for Update<Item, Gap>
|
||||
@@ -110,8 +110,8 @@ where
|
||||
Self::PushItems { position_hint: *position_hint, items: items.clone() }
|
||||
}
|
||||
Self::DetachLastItems { at } => Self::DetachLastItems { at: *at },
|
||||
Self::ReattachItems => Self::ReattachItems,
|
||||
Self::ReattachItemsDone => Self::ReattachItemsDone,
|
||||
Self::StartReattachItems => Self::StartReattachItems,
|
||||
Self::EndReattachItems => Self::EndReattachItems,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user