refactor(indexeddb): track corresponding object store for type in Indexed trait

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
This commit is contained in:
Michael Goldenberg
2025-06-23 17:26:20 -04:00
committed by Ivan Enderlin
parent 60af16ada8
commit c6ce9c560b
2 changed files with 9 additions and 0 deletions

View File

@@ -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.

View File

@@ -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;