mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-20 09:11:24 +01:00
Add PduId wrapper struct
Death to Vec<u8>
This commit is contained in:
parent
341f4213d0
commit
26322d5a95
15 changed files with 110 additions and 71 deletions
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
use ruma::{CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId};
|
||||
|
||||
use super::PduCount;
|
||||
use crate::{PduEvent, Result};
|
||||
use crate::{service::rooms::timeline::PduId, PduEvent, Result};
|
||||
|
||||
pub(crate) trait Data: Send + Sync {
|
||||
fn last_timeline_count(
|
||||
|
|
@ -28,7 +28,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
) -> Result<Option<CanonicalJsonObject>>;
|
||||
|
||||
/// Returns the pdu's id.
|
||||
fn get_pdu_id(&self, event_id: &EventId) -> Result<Option<Vec<u8>>>;
|
||||
fn get_pdu_id(&self, event_id: &EventId) -> Result<Option<PduId>>;
|
||||
|
||||
/// Returns the pdu.
|
||||
///
|
||||
|
|
@ -46,18 +46,18 @@ pub(crate) trait Data: Send + Sync {
|
|||
/// Returns the pdu.
|
||||
///
|
||||
/// This does __NOT__ check the outliers `Tree`.
|
||||
fn get_pdu_from_id(&self, pdu_id: &[u8]) -> Result<Option<PduEvent>>;
|
||||
fn get_pdu_from_id(&self, pdu_id: &PduId) -> Result<Option<PduEvent>>;
|
||||
|
||||
/// Returns the pdu as a `BTreeMap<String, CanonicalJsonValue>`.
|
||||
fn get_pdu_json_from_id(
|
||||
&self,
|
||||
pdu_id: &[u8],
|
||||
pdu_id: &PduId,
|
||||
) -> Result<Option<CanonicalJsonObject>>;
|
||||
|
||||
/// Adds a new pdu to the timeline
|
||||
fn append_pdu(
|
||||
&self,
|
||||
pdu_id: &[u8],
|
||||
pdu_id: &PduId,
|
||||
pdu: &PduEvent,
|
||||
json: &CanonicalJsonObject,
|
||||
count: u64,
|
||||
|
|
@ -66,7 +66,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
// Adds a new pdu to the backfilled timeline
|
||||
fn prepend_backfill_pdu(
|
||||
&self,
|
||||
pdu_id: &[u8],
|
||||
pdu_id: &PduId,
|
||||
event_id: &EventId,
|
||||
json: &CanonicalJsonObject,
|
||||
) -> Result<()>;
|
||||
|
|
@ -74,7 +74,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
/// Removes a pdu and creates a new one with the same id.
|
||||
fn replace_pdu(
|
||||
&self,
|
||||
pdu_id: &[u8],
|
||||
pdu_id: &PduId,
|
||||
pdu_json: &CanonicalJsonObject,
|
||||
pdu: &PduEvent,
|
||||
) -> Result<()>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue