c9effeac326a | atagen | 2026-10-25 10:32 UTC | 1 | use ruma::{OwnedEventId, OwnedRoomId}; |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 2 | #[cfg(feature = "serde")] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 3 | use serde::{Deserialize, Serialize}; |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 4 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 5 | use crate::TimelineEvent; |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 6 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 7 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 8 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 9 | #[non_exhaustive] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 10 | pub enum SearchScope { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 11 | Room(OwnedRoomId), |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 12 | /// a space's rooms, resolved by the host |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 13 | Rooms(Vec<OwnedRoomId>), |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 14 | /// every joined room |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 15 | All, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 16 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 17 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 18 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 19 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 20 | #[non_exhaustive] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 21 | pub enum SearchCommand { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 22 | /// opens a search that owns the media of every hit it hands out. at most 8 stay open, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 23 | /// opening another closes the oldest. words must all match, `"quoted phrases"` match |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 24 | /// in order and `-word` excludes, newest first |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 25 | Search { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 26 | query: String, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 27 | scope: SearchScope, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 28 | limit: u16, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 29 | }, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 30 | /// `cursor` is the previous page's `next_cursor` |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 31 | More { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 32 | search_id: String, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 33 | cursor: String, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 34 | limit: u16, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 35 | }, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 36 | /// frees the search's media. its hits' media ids stop resolving |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 37 | Close { |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 38 | search_id: String, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 39 | }, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 40 | Coverage(SearchScope), |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 41 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 42 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 43 | /// a search's media stay resolvable until it closes, and past `EngineConfig::max_context_media` |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 44 | /// its least recently used are dropped |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 45 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 46 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 47 | pub struct SearchSession { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 48 | pub search_id: String, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 49 | pub page: SearchPage, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 50 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 51 | |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 52 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 53 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 54 | pub enum SearchCloseReason { |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 55 | /// opening a ninth search closed the oldest |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 56 | Evicted, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 57 | } |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 58 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 59 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 60 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 61 | pub struct SearchPage { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 62 | pub hits: Vec<SearchHit>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 63 | /// `None` once there's nothing older that matches |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 64 | pub next_cursor: Option<String>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 65 | pub coverage: SearchCoverage, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 66 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 67 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 68 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 69 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 70 | pub struct SearchHit { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 71 | pub room_id: OwnedRoomId, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 72 | pub event_id: OwnedEventId, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 73 | pub timestamp_ms: u64, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 74 | /// as event context shows it, with the latest edit applied |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 75 | pub event: TimelineEvent, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 76 | /// utf-8 byte ranges of matched words in the content's text, the message body, a |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 77 | /// sticker's body or a poll's question |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 78 | pub matches: Vec<SearchMatch>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 79 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 80 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 81 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 82 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 83 | pub struct SearchMatch { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 84 | pub start: u32, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 85 | pub end: u32, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 86 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 87 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 88 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 89 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 90 | pub struct SearchCoverage { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 91 | pub rooms: Vec<RoomSearchCoverage>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 92 | /// false when the index lives in memory and starts over with the next engine |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 93 | pub persistent: bool, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 94 | /// why it lives in memory, `None` exactly when `persistent` |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 95 | pub in_memory: Option<SearchInMemory>, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 96 | /// messages in scope that couldn't be decrypted yet, so can't be found yet |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 97 | pub undecrypted: usize, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 98 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 99 | |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 100 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 101 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 102 | pub enum SearchInMemory { |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 103 | /// the engine was built without a store, `Engine::from_client` or no store feature |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 104 | NoStore, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 105 | OpenFailed, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 106 | ReadFailed, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 107 | /// five commits in a row failed, so this engine stopped trying |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 108 | CommitFailed, |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 109 | } |
74befbc72baf | atagen | 2026-10-25 11:18 UTC | 110 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 111 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 112 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 113 | pub struct RoomSearchCoverage { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 114 | pub room_id: OwnedRoomId, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 115 | pub oldest_indexed_ms: Option<u64>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 116 | pub newest_indexed_ms: Option<u64>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 117 | /// backfill walked back to the oldest event the server would hand over |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 118 | pub start_reached: bool, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 119 | pub backfill: SearchBackfill, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 120 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 121 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 122 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 123 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 124 | pub enum SearchBackfill { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 125 | Waiting, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 126 | Running, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 127 | /// this engine's page budget for the room is spent, the next one carries on |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 128 | Paused, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 129 | Complete, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 130 | Disabled, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 131 | Failed { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 132 | message: String, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 133 | retry_at_ms: u64, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 134 | }, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 135 | } |