Files
tuwunel/src/service/rooms/directory/mod.rs

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

35 lines
857 B
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
use std::sync::Arc;
use conduit::Server;
use data::Data;
use database::Database;
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;
pub struct Service {
db: Data,
}
2022-10-05 12:45:54 +02:00
impl Service {
pub fn build(_server: &Arc<Server>, db: &Arc<Database>) -> Result<Self> {
Ok(Self {
db: Data::new(db),
})
}
#[tracing::instrument(skip(self))]
pub fn set_public(&self, room_id: &RoomId) -> Result<()> { self.db.set_public(room_id) }
#[tracing::instrument(skip(self))]
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
#[tracing::instrument(skip(self))]
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
#[tracing::instrument(skip(self))]
pub fn public_rooms(&self) -> impl Iterator<Item = Result<OwnedRoomId>> + '_ { self.db.public_rooms() }
}