2022-06-25 16:12:23 +02:00
|
|
|
mod data;
|
2022-10-08 13:04:55 +02:00
|
|
|
|
2022-06-25 16:12:23 +02:00
|
|
|
pub use data::Data;
|
2022-09-06 23:15:09 +02:00
|
|
|
use ruma::RoomId;
|
2020-05-03 17:25:31 +02:00
|
|
|
|
2022-09-07 13:25:51 +02:00
|
|
|
use crate::Result;
|
2020-05-03 17:25:31 +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-06-25 16:12:23 +02:00
|
|
|
}
|
2021-08-12 23:04:00 +02:00
|
|
|
|
2022-10-05 12:45:54 +02:00
|
|
|
impl Service {
|
2022-06-25 16:12:23 +02:00
|
|
|
/// Checks if a room exists.
|
|
|
|
|
#[tracing::instrument(skip(self))]
|
|
|
|
|
pub fn exists(&self, room_id: &RoomId) -> Result<bool> {
|
|
|
|
|
self.db.exists(room_id)
|
2021-08-12 23:04:00 +02:00
|
|
|
}
|
2022-10-05 18:36:12 +02:00
|
|
|
|
2022-10-08 13:02:52 +02:00
|
|
|
pub fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a> {
|
|
|
|
|
self.db.iter_ids()
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-05 18:36:12 +02:00
|
|
|
pub fn is_disabled(&self, room_id: &RoomId) -> Result<bool> {
|
|
|
|
|
self.db.is_disabled(room_id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn disable_room(&self, room_id: &RoomId, disabled: bool) -> Result<()> {
|
|
|
|
|
self.db.disable_room(room_id, disabled)
|
|
|
|
|
}
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|