Files
tuwunel/src/service/rooms/state/data.rs

29 lines
1.1 KiB
Rust
Raw Normal View History

use std::sync::Arc;
use std::{sync::MutexGuard, collections::HashSet};
use std::fmt::Debug;
2022-09-07 13:25:51 +02:00
use crate::Result;
use ruma::{EventId, RoomId};
2022-06-20 11:31:27 +02:00
pub trait Data {
/// Returns the last state hash key added to the db for the given room.
2022-09-07 13:25:51 +02:00
fn get_room_shortstatehash(&self, room_id: &RoomId) -> Result<Option<u64>>;
/// Update the current state of the room.
2022-09-07 13:25:51 +02:00
fn set_room_state(&self, room_id: &RoomId, new_shortstatehash: u64,
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
) -> Result<()>;
/// Associates a state with an event.
2022-09-07 13:25:51 +02:00
fn set_event_state(&self, shorteventid: u64, shortstatehash: u64) -> Result<()>;
/// Returns all events we would send as the prev_events of the next event.
2022-09-07 13:25:51 +02:00
fn get_forward_extremities(&self, room_id: &RoomId) -> Result<HashSet<Arc<EventId>>>;
/// Replace the forward extremities of the room.
2022-09-07 13:25:51 +02:00
fn set_forward_extremities<'a>(&self,
room_id: &RoomId,
2022-09-07 13:25:51 +02:00
event_ids: impl IntoIterator<Item = &'a EventId> + Debug,
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
) -> Result<()>;
}