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 |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 37 | Close { search_id: String }, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 38 | Coverage(SearchScope), |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 39 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 40 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 41 | /// a search's media stay resolvable until it closes, and past `EngineConfig::max_context_media` |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 42 | /// its least recently used are dropped |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 43 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 44 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 45 | pub struct SearchSession { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 46 | pub search_id: String, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 47 | pub page: SearchPage, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 48 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 49 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 50 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 51 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 52 | pub struct SearchPage { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 53 | pub hits: Vec<SearchHit>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 54 | /// `None` once there's nothing older that matches |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 55 | pub next_cursor: Option<String>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 56 | pub coverage: SearchCoverage, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 57 | } |
c9effeac326a | atagen | 2026-10-25 10:32 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 SearchHit { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 62 | pub room_id: OwnedRoomId, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 63 | pub event_id: OwnedEventId, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 64 | pub timestamp_ms: u64, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 65 | /// as event context shows it, with the latest edit applied |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 66 | pub event: TimelineEvent, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 67 | /// utf-8 byte ranges of matched words in the content's text, the message body, a |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 68 | /// sticker's body or a poll's question |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 69 | pub matches: Vec<SearchMatch>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 70 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 71 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 72 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 73 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 74 | pub struct SearchMatch { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 75 | pub start: u32, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 76 | pub end: u32, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 77 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 78 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 79 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 80 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 81 | pub struct SearchCoverage { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 82 | pub rooms: Vec<RoomSearchCoverage>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 83 | /// false when the index lives in memory and starts over with the next engine |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 84 | pub persistent: bool, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 85 | /// messages that couldn't be decrypted yet, so can't be found yet |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 86 | pub undecrypted: usize, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 87 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 88 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 89 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 90 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 91 | pub struct RoomSearchCoverage { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 92 | pub room_id: OwnedRoomId, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 93 | pub oldest_indexed_ms: Option<u64>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 94 | pub newest_indexed_ms: Option<u64>, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 95 | /// backfill walked back to the oldest event the server would hand over |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 96 | pub start_reached: bool, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 97 | pub backfill: SearchBackfill, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 98 | } |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 99 | |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 100 | #[derive(Clone, Debug, Eq, PartialEq)] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 101 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 102 | pub enum SearchBackfill { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 103 | Waiting, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 104 | Running, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 105 | /// this engine's page budget for the room is spent, the next one carries on |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 106 | Paused, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 107 | Complete, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 108 | Disabled, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 109 | Failed { |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 110 | message: String, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 111 | retry_at_ms: u64, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 112 | }, |
c9effeac326a | atagen | 2026-10-25 10:32 UTC | 113 | } |