| 1 | use ruma::{OwnedEventId, OwnedRoomId, OwnedTransactionId}; |
| 2 | |
| 3 | #[cfg(feature = "serde")] |
| 4 | use serde::{Deserialize, Serialize}; |
| 5 | |
| 6 | use crate::Error; |
| 7 | |
| 8 | #[derive(Clone, Debug, PartialEq)] |
| 9 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 10 | #[non_exhaustive] |
| 11 | pub enum HistoryRepairCommand { |
| 12 | /// runs the open-time recent load again, joining one already running. the outcome |
| 13 | /// arrives as `RecentHistoryChanged` |
| 14 | RetryRecent { room_id: OwnedRoomId }, |
| 15 | FillGap { |
| 16 | room_id: OwnedRoomId, |
| 17 | gap_id: OwnedTransactionId, |
| 18 | }, |
| 19 | /// stops whichever history operation the room is running |
| 20 | Cancel { room_id: OwnedRoomId }, |
| 21 | } |
| 22 | |
| 23 | #[derive(Clone, Debug, PartialEq, Eq)] |
| 24 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 25 | pub struct HistoryGap { |
| 26 | pub id: OwnedTransactionId, |
| 27 | pub older_boundary: Option<OwnedEventId>, |
| 28 | pub newer_boundary: Option<OwnedEventId>, |
| 29 | pub lifecycle: HistoryGapLifecycle, |
| 30 | pub failure: Option<String>, |
| 31 | } |
| 32 | |
| 33 | #[derive(Clone, Debug, PartialEq, Eq)] |
| 34 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 35 | pub enum HistoryGapLifecycle { |
| 36 | Idle, |
| 37 | Paused, |
| 38 | Failed, |
| 39 | /// accessible history ends before the older section, so this interval stays |
| 40 | Unavailable, |
| 41 | } |
| 42 | |
| 43 | #[derive(Clone, Debug, PartialEq, Eq)] |
| 44 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 45 | pub enum HistoryContinuity { |
| 46 | Unresolved, |
| 47 | Verified, |
| 48 | AccessibleStart, |
| 49 | } |
| 50 | |
| 51 | #[derive(Clone, Debug, PartialEq)] |
| 52 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 53 | pub enum HistoryRepairPhase { |
| 54 | Bridging, |
| 55 | Ready, |
| 56 | Paused, |
| 57 | } |
| 58 | |
| 59 | #[derive(Clone, Debug, PartialEq)] |
| 60 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 61 | pub enum HistoryRepairStop { |
| 62 | Cancelled, |
| 63 | Budget, |
| 64 | HistoryUnavailable, |
| 65 | CursorStalled, |
| 66 | } |
| 67 | |
| 68 | /// one gap fill. `Bridging` when it starts, then once more when it settles |
| 69 | #[derive(Clone, Debug, PartialEq)] |
| 70 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 71 | pub struct HistoryRepairReport { |
| 72 | pub room_id: OwnedRoomId, |
| 73 | pub gap_id: OwnedTransactionId, |
| 74 | pub pages: u32, |
| 75 | pub events: u32, |
| 76 | pub phase: HistoryRepairPhase, |
| 77 | pub continuity: HistoryContinuity, |
| 78 | pub stop: Option<HistoryRepairStop>, |
| 79 | pub failure: Option<Error>, |
| 80 | } |