From c6ce9c560bc513a5fda718e66adc8f247341d0e2 Mon Sep 17 00:00:00 2001 From: Michael Goldenberg Date: Mon, 23 Jun 2025 17:26:20 -0400 Subject: [PATCH] refactor(indexeddb): track corresponding object store for type in Indexed trait Signed-off-by: Michael Goldenberg --- .../src/event_cache_store/serializer/traits.rs | 3 +++ .../src/event_cache_store/serializer/types.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/traits.rs b/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/traits.rs index 16e471932..b5e59bc71 100644 --- a/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/traits.rs +++ b/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/traits.rs @@ -24,6 +24,9 @@ use crate::serializer::IndexeddbSerializer; /// decryption, in the case the high-level type must be encrypted before /// storage. pub trait Indexed: Sized { + /// The name of the object store in IndexedDB. + const OBJECT_STORE: &'static str; + /// The indexed type that is used for storage in IndexedDB. type IndexedType; /// The error type that is returned when conversion fails. diff --git a/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/types.rs b/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/types.rs index 8193b216f..8a6be6d57 100644 --- a/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/types.rs +++ b/crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/types.rs @@ -144,6 +144,8 @@ pub struct IndexedChunk { } impl Indexed for Chunk { + const OBJECT_STORE: &'static str = keys::LINKED_CHUNKS; + type IndexedType = IndexedChunk; type Error = CryptoStoreError; @@ -300,6 +302,8 @@ pub enum IndexedEventError { } impl Indexed for Event { + const OBJECT_STORE: &'static str = keys::EVENTS; + type IndexedType = IndexedEvent; type Error = IndexedEventError; @@ -460,6 +464,8 @@ pub struct IndexedGap { } impl Indexed for Gap { + const OBJECT_STORE: &'static str = keys::GAPS; + type IndexedType = IndexedGap; type Error = CryptoStoreError;