Files
continuwuity/src/service/rooms/directory/mod.rs
T

36 lines
996 B
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
2024-05-09 15:59:08 -07:00
use std::sync::Arc;
2024-07-18 06:37:47 +00:00
use conduit::Result;
2022-10-09 17:25:06 +02:00
use ruma::{OwnedRoomId, RoomId};
2024-07-18 06:37:47 +00:00
use self::data::Data;
2024-05-09 15:59:08 -07:00
pub struct Service {
2024-05-27 03:17:20 +00:00
db: Data,
}
2024-07-04 03:26:19 +00:00
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data::new(args.db),
}))
2024-05-27 03:17:20 +00:00
}
2024-07-04 03:26:19 +00:00
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}
impl Service {
2024-07-07 19:03:15 +00:00
#[tracing::instrument(skip(self), level = "debug")]
2024-05-09 15:59:08 -07:00
pub fn set_public(&self, room_id: &RoomId) -> Result<()> { self.db.set_public(room_id) }
2020-05-25 23:24:13 +02:00
2024-07-07 19:03:15 +00:00
#[tracing::instrument(skip(self), level = "debug")]
2024-05-09 15:59:08 -07:00
pub fn set_not_public(&self, room_id: &RoomId) -> Result<()> { self.db.set_not_public(room_id) }
2020-05-25 23:24:13 +02:00
2024-07-07 19:03:15 +00:00
#[tracing::instrument(skip(self), level = "debug")]
2024-05-09 15:59:08 -07:00
pub fn is_public_room(&self, room_id: &RoomId) -> Result<bool> { self.db.is_public_room(room_id) }
2020-05-25 23:24:13 +02:00
2024-07-07 19:03:15 +00:00
#[tracing::instrument(skip(self), level = "debug")]
2024-05-09 15:59:08 -07:00
pub fn public_rooms(&self) -> impl Iterator<Item = Result<OwnedRoomId>> + '_ { self.db.public_rooms() }
}