Skip to content

Commit

Permalink
feat(event cache): include the lazy previous chunk in the debug strin…
Browse files Browse the repository at this point in the history
…g, if available
  • Loading branch information
bnjbvr committed Feb 24, 2025
1 parent 66b9d33 commit 39c6481
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions crates/matrix-sdk-common/src/linked_chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,14 @@ impl<const CAPACITY: usize, Item, Gap> Chunk<CAPACITY, Item, Gap> {
self.next.is_none()
}

/// Return the link to the previous chunk, if it was loaded lazily.
///
/// Doc hidden because this is mostly for internal debugging purposes.
#[doc(hidden)]
pub fn lazy_previous(&self) -> Option<ChunkIdentifier> {
self.lazy_previous
}

/// Get the unique identifier of the chunk.
pub fn identifier(&self) -> ChunkIdentifier {
self.identifier
Expand Down
7 changes: 6 additions & 1 deletion crates/matrix-sdk/src/event_cache/room/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ impl RoomEvents {

for chunk in self.chunks() {
let content = chunk_debug_string(chunk.content());
let line = format!("chunk #{}: {content}", chunk.identifier().index());
let lazy_previous = if let Some(cid) = chunk.lazy_previous() {
format!(" (lazy previous = {})", cid.index())
} else {
"".to_owned()
};
let line = format!("chunk #{}{lazy_previous}: {content}", chunk.identifier().index());

result.push(line);
}
Expand Down

0 comments on commit 39c6481

Please sign in to comment.