refactor(event cache): add first_chunk_as_gap() in EventLinkedChunk too

This commit is contained in:
Benjamin Bouvier
2026-03-03 15:09:47 +01:00
parent 4b23378d29
commit dd5cb220a0
2 changed files with 12 additions and 9 deletions

View File

@@ -277,16 +277,8 @@ impl EventFocusedCacheInner {
}
/// Return the first chunk as a gap, if it's one.
///
/// This stores the backward pagination token, in this case.
fn first_chunk_as_gap(&self) -> Option<(ChunkIdentifier, Gap)> {
self.chunk.chunks().next().and_then(|chunk| {
if let ChunkContent::Gap(gap) = chunk.content() {
Some((chunk.identifier(), gap.clone()))
} else {
None
}
})
self.chunk.first_chunk_as_gap()
}
/// Return the last chunk as a gap, if it's one.

View File

@@ -507,6 +507,17 @@ impl EventLinkedChunk {
replaced_some
}
/// Return the first chunk as a gap, if it's one.
pub fn first_chunk_as_gap(&self) -> Option<(ChunkIdentifier, Gap)> {
self.chunks().next().and_then(|chunk| {
if let ChunkContent::Gap(gap) = chunk.content() {
Some((chunk.identifier(), gap.clone()))
} else {
None
}
})
}
}
// Methods related to lazy-loading.