refactor(indexeddb): add conversion IndexeddbSerializerError -> IndexeddbCryptoStoreError

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
This commit is contained in:
Michael Goldenberg
2025-05-01 11:55:11 -04:00
committed by Ivan Enderlin
parent c2e859273d
commit 3f3daef01c
2 changed files with 15 additions and 1 deletions

View File

@@ -39,7 +39,6 @@ pub struct IndexeddbSerializer {
store_cipher: Option<Arc<StoreCipher>>,
}
#[allow(dead_code)]
#[derive(Debug, thiserror::Error)]
pub enum IndexeddbSerializerError {
#[error(transparent)]

View File

@@ -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<IndexeddbSerializerError> 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<web_sys::DomException> for IndexeddbCryptoStoreError {
fn from(frm: web_sys::DomException) -> IndexeddbCryptoStoreError {
IndexeddbCryptoStoreError::DomException {