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-10-09 17:25:06 +02:00
|
|
|
use ruma::{OwnedRoomId, 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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2022-10-05 12:45:54 +02:00
|
|
|
impl Service {
|
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))]
|
2022-10-09 17:25:06 +02:00
|
|
|
pub fn public_rooms(&self) -> impl Iterator<Item = Result<OwnedRoomId>> + '_ {
|
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
|
|
|
}
|