diff --git a/crates/matrix-sdk-indexeddb/src/event_cache_store/builder.rs b/crates/matrix-sdk-indexeddb/src/event_cache_store/builder.rs index 87b52e17f..d2be31922 100644 --- a/crates/matrix-sdk-indexeddb/src/event_cache_store/builder.rs +++ b/crates/matrix-sdk-indexeddb/src/event_cache_store/builder.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License -use std::sync::Arc; +use std::{rc::Rc, sync::Arc}; use matrix_sdk_base::event_cache::store::MemoryStore; use matrix_sdk_store_encryption::StoreCipher; @@ -66,7 +66,7 @@ impl IndexeddbEventCacheStoreBuilder { /// and the provided store cipher. pub async fn build(self) -> Result { Ok(IndexeddbEventCacheStore { - inner: open_and_upgrade_db(&self.database_name).await?, + inner: Rc::new(open_and_upgrade_db(&self.database_name).await?), serializer: IndexeddbEventCacheStoreSerializer::new(IndexeddbSerializer::new( self.store_cipher, )), diff --git a/crates/matrix-sdk-indexeddb/src/event_cache_store/mod.rs b/crates/matrix-sdk-indexeddb/src/event_cache_store/mod.rs index 72376cbcc..df499cfcc 100644 --- a/crates/matrix-sdk-indexeddb/src/event_cache_store/mod.rs +++ b/crates/matrix-sdk-indexeddb/src/event_cache_store/mod.rs @@ -14,7 +14,7 @@ #![allow(unused)] -use std::time::Duration; +use std::{rc::Rc, time::Duration}; use indexed_db_futures::IdbDatabase; use matrix_sdk_base::{ @@ -63,10 +63,10 @@ pub use error::IndexeddbEventCacheStoreError; /// contexts. /// /// [1]: matrix_sdk_base::event_cache::store::EventCacheStore -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct IndexeddbEventCacheStore { // A handle to the IndexedDB database - inner: IdbDatabase, + inner: Rc, // A serializer with functionality tailored to `IndexeddbEventCacheStore` serializer: IndexeddbEventCacheStoreSerializer, // An in-memory store for providing temporary implementations for diff --git a/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/mod.rs b/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/mod.rs index 78817f6da..d15cea801 100644 --- a/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/mod.rs +++ b/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/mod.rs @@ -52,7 +52,7 @@ impl From for IndexeddbEventCacheStoreSerializerEr /// [`EventCacheStore`][1]. /// /// [1]: matrix_sdk_base::event_cache::store::EventCacheStore -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct IndexeddbEventCacheStoreSerializer { inner: IndexeddbSerializer, } diff --git a/crates/matrix-sdk-indexeddb/src/serializer.rs b/crates/matrix-sdk-indexeddb/src/serializer.rs index c6b504055..cb29b1ee7 100644 --- a/crates/matrix-sdk-indexeddb/src/serializer.rs +++ b/crates/matrix-sdk-indexeddb/src/serializer.rs @@ -35,6 +35,7 @@ const BASE64: GeneralPurpose = GeneralPurpose::new(&alphabet::STANDARD, general_ /// Handles the functionality of serializing and encrypting data for the /// indexeddb store. +#[derive(Clone)] pub struct IndexeddbSerializer { store_cipher: Option>, }