grapevine/src/service/rooms/short/data.rs
2024-10-20 13:29:33 -07:00

50 lines
1.3 KiB
Rust

use std::sync::Arc;
use ruma::{events::StateEventType, EventId, RoomId};
use super::{ShortEventId, ShortRoomId, ShortStateHash, ShortStateKey};
use crate::Result;
pub(crate) trait Data: Send + Sync {
/// The returned bool indicates whether it was created
fn get_or_create_shorteventid(
&self,
event_id: &EventId,
) -> Result<(ShortEventId, bool)>;
fn get_shortstatekey(
&self,
event_type: &StateEventType,
state_key: &str,
) -> Result<Option<ShortStateKey>>;
/// The returned bool indicates whether it was created
fn get_or_create_shortstatekey(
&self,
event_type: &StateEventType,
state_key: &str,
) -> Result<(ShortStateKey, bool)>;
fn get_eventid_from_short(
&self,
shorteventid: ShortEventId,
) -> Result<Arc<EventId>>;
fn get_statekey_from_short(
&self,
shortstatekey: ShortStateKey,
) -> Result<(StateEventType, String)>;
/// Returns `(shortstatehash, already_existed)`
fn get_or_create_shortstatehash(
&self,
state_hash: &[u8],
) -> Result<(ShortStateHash, bool)>;
fn get_shortroomid(&self, room_id: &RoomId) -> Result<Option<ShortRoomId>>;
fn get_or_create_shortroomid(
&self,
room_id: &RoomId,
) -> Result<ShortRoomId>;
}