Skip to content

Commit 3f3daef

Browse files
mgoldenbergHywan
authored andcommitted
refactor(indexeddb): add conversion IndexeddbSerializerError -> IndexeddbCryptoStoreError
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
1 parent c2e8592 commit 3f3daef

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

crates/matrix-sdk-indexeddb/src/crypto_store/indexeddb_serializer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub struct IndexeddbSerializer {
3939
store_cipher: Option<Arc<StoreCipher>>,
4040
}
4141

42-
#[allow(dead_code)]
4342
#[derive(Debug, thiserror::Error)]
4443
pub enum IndexeddbSerializerError {
4544
#[error(transparent)]

crates/matrix-sdk-indexeddb/src/crypto_store/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use async_trait::async_trait;
2121
use gloo_utils::format::JsValueSerdeExt;
2222
use hkdf::Hkdf;
2323
use indexed_db_futures::prelude::*;
24+
use indexeddb_serializer::IndexeddbSerializerError;
2425
use js_sys::Array;
2526
use matrix_sdk_crypto::{
2627
olm::{
@@ -148,6 +149,20 @@ pub enum IndexeddbCryptoStoreError {
148149
SchemaTooNewError { max_supported_version: u32, current_version: u32 },
149150
}
150151

152+
impl From<IndexeddbSerializerError> for IndexeddbCryptoStoreError {
153+
fn from(value: IndexeddbSerializerError) -> Self {
154+
match value {
155+
IndexeddbSerializerError::Serialization(error) => Self::Serialization(error),
156+
IndexeddbSerializerError::DomException { code, name, message } => {
157+
Self::DomException { code, name, message }
158+
}
159+
IndexeddbSerializerError::CryptoStoreError(crypto_store_error) => {
160+
Self::CryptoStoreError(crypto_store_error)
161+
}
162+
}
163+
}
164+
}
165+
151166
impl From<web_sys::DomException> for IndexeddbCryptoStoreError {
152167
fn from(frm: web_sys::DomException) -> IndexeddbCryptoStoreError {
153168
IndexeddbCryptoStoreError::DomException {

0 commit comments

Comments
 (0)