conduwuit/src/service/rooms/state/data.rs

33 lines
1.2 KiB
Rust
Raw Normal View History

2022-09-07 13:25:51 +02:00
use crate::Result;
2022-10-09 17:25:06 +02:00
use ruma::{EventId, OwnedEventId, RoomId};
2022-10-05 20:34:31 +02:00
use std::collections::HashSet;
use std::sync::Arc;
2022-10-05 15:33:57 +02:00
use tokio::sync::MutexGuard;
2022-10-05 15:33:57 +02:00
pub trait Data: Send + Sync {
/// 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>>;
/// Set the state hash to a new version, but does not update state_cache.
2022-10-05 20:34:31 +02:00
fn set_room_state(
&self,
room_id: &RoomId,
new_shortstatehash: u64,
2022-09-07 13:25:51 +02:00
_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-10-05 20:34:31 +02:00
fn set_forward_extremities<'a>(
&self,
room_id: &RoomId,
2022-10-09 17:25:06 +02:00
event_ids: Vec<OwnedEventId>,
2022-09-07 13:25:51 +02:00
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
) -> Result<()>;
}