conduwuit/src/service/rooms/search/mod.rs

28 lines
645 B
Rust
Raw Normal View History

2022-07-10 16:28:43 +02:00
mod data;
2022-10-05 18:36:12 +02:00
use std::sync::Arc;
2022-07-10 16:28:43 +02:00
pub use data::Data;
2022-09-07 13:25:51 +02:00
use crate::Result;
use ruma::RoomId;
2022-07-10 16:28:43 +02:00
2022-10-05 12:45:54 +02:00
pub struct Service {
2022-10-08 13:02:52 +02:00
pub db: &'static dyn Data,
2022-07-10 16:28:43 +02:00
}
2022-10-05 12:45:54 +02:00
impl Service {
#[tracing::instrument(skip(self))]
2022-10-08 13:03:07 +02:00
pub fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> {
2022-10-05 12:45:54 +02:00
self.db.index_pdu(shortroomid, pdu_id, message_body)
}
#[tracing::instrument(skip(self))]
pub fn search_pdus<'a>(
&'a self,
2020-08-18 12:15:27 +02:00
room_id: &RoomId,
search_string: &str,
2022-02-04 17:15:21 +01:00
) -> Result<Option<(impl Iterator<Item = Vec<u8>> + 'a, Vec<String>)>> {
2022-07-10 16:28:43 +02:00
self.db.search_pdus(room_id, search_string)
}
2022-07-10 16:28:43 +02:00
}