Skip to content

Commit 67ff82e

Browse files
committed
feat(base): Add EventCacheStore::handle_linked_chunk_updates.
This patch adds the `handle_linked_chunk_updates` method on the `EventCacheStore` trait. Part of #3280.
1 parent 8a6ced0 commit 67ff82e

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

crates/matrix-sdk-base/src/event_cache/store/memory_store.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ use std::{collections::HashMap, num::NonZeroUsize, sync::RwLock as StdRwLock, ti
1616

1717
use async_trait::async_trait;
1818
use matrix_sdk_common::{
19-
ring_buffer::RingBuffer, store_locks::memory_store_helper::try_take_leased_lock,
19+
linked_chunk::Update, ring_buffer::RingBuffer,
20+
store_locks::memory_store_helper::try_take_leased_lock,
2021
};
2122
use ruma::{MxcUri, OwnedMxcUri};
2223

2324
use super::{EventCacheStore, EventCacheStoreError, Result};
24-
use crate::media::{MediaRequestParameters, UniqueKey as _};
25+
use crate::{
26+
event_cache::{Event, Gap},
27+
media::{MediaRequestParameters, UniqueKey as _},
28+
};
2529

2630
/// In-memory, non-persistent implementation of the `EventCacheStore`.
2731
///
@@ -66,6 +70,13 @@ impl EventCacheStore for MemoryStore {
6670
Ok(try_take_leased_lock(&self.leases, lease_duration_ms, key, holder))
6771
}
6872

73+
async fn handle_linked_chunk_updates(
74+
&self,
75+
updates: &[Update<Event, Gap>],
76+
) -> Result<(), Self::Error> {
77+
todo!()
78+
}
79+
6980
async fn add_media_content(
7081
&self,
7182
request: &MediaRequestParameters,

crates/matrix-sdk-base/src/event_cache/store/traits.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
use std::{fmt, sync::Arc};
1616

1717
use async_trait::async_trait;
18-
use matrix_sdk_common::AsyncTraitDeps;
18+
use matrix_sdk_common::{linked_chunk::Update, AsyncTraitDeps};
1919
use ruma::MxcUri;
2020

2121
use super::EventCacheStoreError;
22-
use crate::media::MediaRequestParameters;
22+
use crate::{
23+
event_cache::{Event, Gap},
24+
media::MediaRequestParameters,
25+
};
2326

2427
/// An abstract trait that can be used to implement different store backends
2528
/// for the event cache of the SDK.
@@ -37,6 +40,11 @@ pub trait EventCacheStore: AsyncTraitDeps {
3740
holder: &str,
3841
) -> Result<bool, Self::Error>;
3942

43+
async fn handle_linked_chunk_updates(
44+
&self,
45+
updates: &[Update<Event, Gap>],
46+
) -> Result<(), Self::Error>;
47+
4048
/// Add a media file's content in the media store.
4149
///
4250
/// # Arguments
@@ -131,6 +139,13 @@ impl<T: EventCacheStore> EventCacheStore for EraseEventCacheStoreError<T> {
131139
self.0.try_take_leased_lock(lease_duration_ms, key, holder).await.map_err(Into::into)
132140
}
133141

142+
async fn handle_linked_chunk_updates(
143+
&self,
144+
updates: &[Update<Event, Gap>],
145+
) -> Result<(), Self::Error> {
146+
self.0.handle_linked_chunk_updates(updates).await.map_err(Into::into)
147+
}
148+
134149
async fn add_media_content(
135150
&self,
136151
request: &MediaRequestParameters,

crates/matrix-sdk-common/src/linked_chunk/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ use std::{
103103
sync::atomic::{AtomicU64, Ordering},
104104
};
105105

106-
use as_vector::*;
107-
use updates::*;
106+
pub use as_vector::*;
107+
pub use updates::*;
108108

109109
/// Errors of [`LinkedChunk`].
110110
#[derive(thiserror::Error, Debug)]

crates/matrix-sdk-sqlite/src/event_cache_store.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ impl EventCacheStore for SqliteEventCacheStore {
182182
Ok(num_touched == 1)
183183
}
184184

185+
async fn handle_linked_chunk_updates(
186+
&self,
187+
updates: &[Update<Event, Gap>],
188+
) -> Result<(), Self::Error> {
189+
todo!()
190+
}
191+
185192
async fn add_media_content(
186193
&self,
187194
request: &MediaRequestParameters,

0 commit comments

Comments
 (0)