mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
Add wrapper types for short IDs
This commit is contained in:
parent
f1642c92d1
commit
b0f33207fe
28 changed files with 427 additions and 232 deletions
|
|
@ -2,38 +2,47 @@ 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 {
|
||||
fn get_or_create_shorteventid(&self, event_id: &EventId) -> Result<u64>;
|
||||
fn get_or_create_shorteventid(
|
||||
&self,
|
||||
event_id: &EventId,
|
||||
) -> Result<ShortEventId>;
|
||||
|
||||
fn get_shortstatekey(
|
||||
&self,
|
||||
event_type: &StateEventType,
|
||||
state_key: &str,
|
||||
) -> Result<Option<u64>>;
|
||||
) -> Result<Option<ShortStateKey>>;
|
||||
|
||||
fn get_or_create_shortstatekey(
|
||||
&self,
|
||||
event_type: &StateEventType,
|
||||
state_key: &str,
|
||||
) -> Result<u64>;
|
||||
) -> Result<ShortStateKey>;
|
||||
|
||||
fn get_eventid_from_short(&self, shorteventid: u64)
|
||||
-> Result<Arc<EventId>>;
|
||||
fn get_eventid_from_short(
|
||||
&self,
|
||||
shorteventid: ShortEventId,
|
||||
) -> Result<Arc<EventId>>;
|
||||
|
||||
fn get_statekey_from_short(
|
||||
&self,
|
||||
shortstatekey: u64,
|
||||
shortstatekey: ShortStateKey,
|
||||
) -> Result<(StateEventType, String)>;
|
||||
|
||||
/// Returns `(shortstatehash, already_existed)`
|
||||
fn get_or_create_shortstatehash(
|
||||
&self,
|
||||
state_hash: &[u8],
|
||||
) -> Result<(u64, bool)>;
|
||||
) -> Result<(ShortStateHash, bool)>;
|
||||
|
||||
fn get_shortroomid(&self, room_id: &RoomId) -> Result<Option<u64>>;
|
||||
fn get_shortroomid(&self, room_id: &RoomId) -> Result<Option<ShortRoomId>>;
|
||||
|
||||
fn get_or_create_shortroomid(&self, room_id: &RoomId) -> Result<u64>;
|
||||
fn get_or_create_shortroomid(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
) -> Result<ShortRoomId>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue