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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
909 B
Rust
Raw Normal View History

2022-07-10 16:28:43 +02:00
mod data;
2022-10-08 13:04:55 +02:00
use std::sync::Arc;
use conduit::{Result, Server};
use data::Data;
use database::Database;
use ruma::RoomId;
2022-09-07 13:25:51 +02:00
pub struct Service {
db: Data,
2022-07-10 16:28:43 +02:00
}
2022-10-05 12:45:54 +02:00
impl Service {
pub fn build(_server: &Arc<Server>, db: &Arc<Database>) -> Result<Self> {
Ok(Self {
db: Data::new(db),
})
}
2022-10-05 12:45:54 +02:00
#[tracing::instrument(skip(self))]
pub fn index_pdu(&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 deindex_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> {
self.db.deindex_pdu(shortroomid, pdu_id, message_body)
}
#[tracing::instrument(skip(self))]
pub fn search_pdus<'a>(
2020-08-18 12:15:27 +02:00
&'a self, 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
}