enrich state iteration interface
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
7680d1bd5e
commit
411c60009d
4 changed files with 117 additions and 107 deletions
|
@ -17,7 +17,7 @@ use ruma::{EventId, RoomId};
|
|||
|
||||
use crate::{
|
||||
rooms,
|
||||
rooms::short::{ShortId, ShortStateHash, ShortStateKey},
|
||||
rooms::short::{ShortEventId, ShortId, ShortStateHash, ShortStateKey},
|
||||
Dep,
|
||||
};
|
||||
|
||||
|
@ -196,24 +196,6 @@ impl Service {
|
|||
.expect("failed to create CompressedStateEvent")
|
||||
}
|
||||
|
||||
/// Returns shortstatekey, event id
|
||||
#[inline]
|
||||
pub async fn parse_compressed_state_event(
|
||||
&self, compressed_event: CompressedStateEvent,
|
||||
) -> Result<(ShortStateKey, Arc<EventId>)> {
|
||||
use utils::u64_from_u8;
|
||||
|
||||
let shortstatekey = u64_from_u8(&compressed_event[0..size_of::<ShortStateKey>()]);
|
||||
let shorteventid = u64_from_u8(&compressed_event[size_of::<ShortStateKey>()..]);
|
||||
let event_id = self
|
||||
.services
|
||||
.short
|
||||
.get_eventid_from_short(shorteventid)
|
||||
.await?;
|
||||
|
||||
Ok((shortstatekey, event_id))
|
||||
}
|
||||
|
||||
/// Creates a new shortstatehash that often is just a diff to an already
|
||||
/// existing shortstatehash and therefore very efficient.
|
||||
///
|
||||
|
@ -488,6 +470,17 @@ impl Service {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn parse_compressed_state_event(compressed_event: CompressedStateEvent) -> (ShortStateKey, ShortEventId) {
|
||||
use utils::u64_from_u8;
|
||||
|
||||
let shortstatekey = u64_from_u8(&compressed_event[0..size_of::<ShortStateKey>()]);
|
||||
let shorteventid = u64_from_u8(&compressed_event[size_of::<ShortStateKey>()..]);
|
||||
|
||||
(shortstatekey, shorteventid)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn compressed_state_size(compressed_state: &CompressedState) -> usize {
|
||||
compressed_state
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue