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

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

41 lines
983 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;
use data::Data;
use ruma::RoomId;
2022-09-07 13:25:51 +02:00
pub struct Service {
db: Data,
2022-07-10 16:28:43 +02:00
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data::new(args.db),
}))
}
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}
impl Service {
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
}