diff --git a/crates/matrix-sdk-sled/src/state_store.rs b/crates/matrix-sdk-sled/src/state_store.rs index f03181dfe..db9838ece 100644 --- a/crates/matrix-sdk-sled/src/state_store.rs +++ b/crates/matrix-sdk-sled/src/state_store.rs @@ -59,6 +59,9 @@ use sled::{ use tokio::task::spawn_blocking; use tracing::{info, warn}; +#[cfg(feature = "encryption")] +pub use crate::CryptoStore; + #[derive(Debug, Serialize, Deserialize)] pub enum DatabaseType { Unencrypted, @@ -377,6 +380,14 @@ impl SledStore { SledStore::open_helper(db, Some(path), None) } + #[cfg(feature = "encryption")] + /// Open a `CryptoStore` that uses the same database as this store. + /// + /// The given passphrase will be used to encrypt private data. + pub fn get_crypto_store(&self, passphrase: Option<&str>) -> Result { + CryptoStore::open_with_database(self.inner.clone(), passphrase) + } + fn serialize_event(&self, event: &impl Serialize) -> Result, SledStoreError> { if let Some(key) = &*self.store_key { let encrypted = key.encrypt(event)?;