2022-06-25 16:12:23 +02:00
|
|
|
mod data;
|
|
|
|
|
pub use data::Data;
|
2022-09-06 23:15:09 +02:00
|
|
|
use ruma::RoomId;
|
2020-05-25 23:24:13 +02:00
|
|
|
|
2022-09-07 13:25:51 +02:00
|
|
|
use crate::Result;
|
2022-06-25 16:12:23 +02:00
|
|
|
|
|
|
|
|
pub struct Service<D: Data> {
|
|
|
|
|
db: D,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-07 13:25:51 +02:00
|
|
|
impl<D: Data> Service<D> {
|
2021-07-29 08:36:01 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
2022-06-25 16:12:23 +02:00
|
|
|
pub fn set_public(&self, room_id: &RoomId) -> Result<()> {
|
2022-09-06 23:15:09 +02:00
|
|
|
self.db.set_public(room_id)
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|
2020-05-24 08:30:57 +02:00
|
|
|
|
2022-06-25 16:12:23 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
|
|
|
|
pub fn set_not_public(&self, room_id: &RoomId) -> Result<()> {
|
2022-09-06 23:15:09 +02:00
|
|
|
self.db.set_not_public(room_id)
|
2020-05-25 23:24:13 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-29 08:36:01 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
2020-05-25 23:24:13 +02:00
|
|
|
pub fn is_public_room(&self, room_id: &RoomId) -> Result<bool> {
|
2022-09-06 23:15:09 +02:00
|
|
|
self.db.is_public_room(room_id)
|
2020-05-25 23:24:13 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-29 08:36:01 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
2021-11-26 20:36:40 +01:00
|
|
|
pub fn public_rooms(&self) -> impl Iterator<Item = Result<Box<RoomId>>> + '_ {
|
2022-09-06 23:15:09 +02:00
|
|
|
self.db.public_rooms()
|
2020-05-24 08:30:57 +02:00
|
|
|
}
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|