Skip to content

Commit 52f24e9

Browse files
committed
common: add TimelineSlice
The TimelineSlice is a slice of the timeline of a room and contains the start and end of the slice.
1 parent c155081 commit 52f24e9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

matrix_sdk_common/src/deserialized_responses.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,26 @@ impl Timeline {
242242
}
243243
}
244244

245+
/// A slice of the timeline in the room.
246+
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
247+
pub struct TimelineSlice {
248+
/// The `next_batch` or `from` token used to obtain this slice
249+
pub start: String,
250+
251+
/// The `prev_batch` or `to` token used to obtain this slice
252+
/// If `None` this `TimelineSlice` is the begining of the room
253+
pub end: Option<String>,
254+
255+
/// A list of events.
256+
pub events: Vec<SyncRoomEvent>,
257+
}
258+
259+
impl TimelineSlice {
260+
pub fn new(events: Vec<SyncRoomEvent>, start: String, end: Option<String>) -> Self {
261+
Self { start, end, events }
262+
}
263+
}
264+
245265
#[derive(Clone, Debug, Deserialize, Serialize)]
246266
#[serde(
247267
try_from = "SyncStateEvent<MemberEventContent>",

0 commit comments

Comments
 (0)