common: add TimelineSlice
The TimelineSlice is a slice of the timeline of a room and contains the
start and end of the slice.
@@ -255,6 +255,33 @@ impl Timeline {
}
}
+/// A slice of the timeline in the room.
+#[derive(Clone, Debug, Default, Deserialize, Serialize)]
+pub struct TimelineSlice {
+ /// The `next_batch` or `from` token used to obtain this slice
+ pub start: String,
+
+ /// The `prev_batch` or `to` token used to obtain this slice
+ /// If `None` this `TimelineSlice` is the beginning of the room
+ pub end: Option<String>,
+
+ /// Whether the number of events returned for this slice was limited
+ /// by a `limit`-filter when requesting
+ pub limited: bool,
+
+ /// A list of events.
+ pub events: Vec<SyncRoomEvent>,
+
+ /// Whether this is a timeline slice obtained from a `SyncResponse`
+ pub sync: bool,
+}
+
+impl TimelineSlice {
+ pub fn new(events: Vec<SyncRoomEvent>, start: String, end: Option<String>, limited: bool) -> Self {
+ Self { start, end, events, limited }
+ }
+}
+
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(try_from = "SyncRoomMemberEvent", into = "SyncRoomMemberEvent")]
pub struct MemberEvent {
