feat(indexeddb): derive Clone for IndexeddbEventCacheStore

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
This commit is contained in:
Michael Goldenberg
2025-08-25 15:06:29 -04:00
committed by Ivan Enderlin
parent f4ce4356ab
commit b77c6c65cc
4 changed files with 7 additions and 6 deletions

View File

@@ -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<IndexeddbEventCacheStore, IndexeddbEventCacheStoreError> {
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,
)),

View File

@@ -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<IdbDatabase>,
// A serializer with functionality tailored to `IndexeddbEventCacheStore`
serializer: IndexeddbEventCacheStoreSerializer,
// An in-memory store for providing temporary implementations for

View File

@@ -52,7 +52,7 @@ impl<T> From<serde_wasm_bindgen::Error> for IndexeddbEventCacheStoreSerializerEr
/// [`EventCacheStore`][1].
///
/// [1]: matrix_sdk_base::event_cache::store::EventCacheStore
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct IndexeddbEventCacheStoreSerializer {
inner: IndexeddbSerializer,
}

View File

@@ -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<Arc<StoreCipher>>,
}