From 3f3daef01cbf3f10f8f3a37ccba9f210866cfc35 Mon Sep 17 00:00:00 2001 From: Michael Goldenberg Date: Thu, 1 May 2025 11:55:11 -0400 Subject: [PATCH] refactor(indexeddb): add conversion IndexeddbSerializerError -> IndexeddbCryptoStoreError Signed-off-by: Michael Goldenberg --- .../src/crypto_store/indexeddb_serializer.rs | 1 - .../matrix-sdk-indexeddb/src/crypto_store/mod.rs | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk-indexeddb/src/crypto_store/indexeddb_serializer.rs b/crates/matrix-sdk-indexeddb/src/crypto_store/indexeddb_serializer.rs index 40dde29cb..f790bb02d 100644 --- a/crates/matrix-sdk-indexeddb/src/crypto_store/indexeddb_serializer.rs +++ b/crates/matrix-sdk-indexeddb/src/crypto_store/indexeddb_serializer.rs @@ -39,7 +39,6 @@ pub struct IndexeddbSerializer { store_cipher: Option>, } -#[allow(dead_code)] #[derive(Debug, thiserror::Error)] pub enum IndexeddbSerializerError { #[error(transparent)] diff --git a/crates/matrix-sdk-indexeddb/src/crypto_store/mod.rs b/crates/matrix-sdk-indexeddb/src/crypto_store/mod.rs index 520c3d038..a35b00442 100644 --- a/crates/matrix-sdk-indexeddb/src/crypto_store/mod.rs +++ b/crates/matrix-sdk-indexeddb/src/crypto_store/mod.rs @@ -21,6 +21,7 @@ use async_trait::async_trait; use gloo_utils::format::JsValueSerdeExt; use hkdf::Hkdf; use indexed_db_futures::prelude::*; +use indexeddb_serializer::IndexeddbSerializerError; use js_sys::Array; use matrix_sdk_crypto::{ olm::{ @@ -148,6 +149,20 @@ pub enum IndexeddbCryptoStoreError { SchemaTooNewError { max_supported_version: u32, current_version: u32 }, } +impl From for IndexeddbCryptoStoreError { + fn from(value: IndexeddbSerializerError) -> Self { + match value { + IndexeddbSerializerError::Serialization(error) => Self::Serialization(error), + IndexeddbSerializerError::DomException { code, name, message } => { + Self::DomException { code, name, message } + } + IndexeddbSerializerError::CryptoStoreError(crypto_store_error) => { + Self::CryptoStoreError(crypto_store_error) + } + } + } +} + impl From for IndexeddbCryptoStoreError { fn from(frm: web_sys::DomException) -> IndexeddbCryptoStoreError { IndexeddbCryptoStoreError::DomException {