diff --git a/bindings/matrix-sdk-ffi/src/client_builder.rs b/bindings/matrix-sdk-ffi/src/client_builder.rs index 7abd342f7..8249c8775 100644 --- a/bindings/matrix-sdk-ffi/src/client_builder.rs +++ b/bindings/matrix-sdk-ffi/src/client_builder.rs @@ -1,3 +1,6 @@ +// Allow UniFFI to use methods marked as `#[deprecated]`. +#![allow(deprecated)] + use std::{num::NonZeroUsize, sync::Arc, time::Duration}; #[cfg(not(target_family = "wasm"))] @@ -526,6 +529,20 @@ impl ClientBuilder { builder.store = Some(StoreBuilder::Sqlite(unwrap_or_clone_arc(config))); Arc::new(builder) } + + /// Sets the paths that the client will use to store its data and caches + /// with SQLite. + /// + /// Both paths **must** be unique per session as the SDK + /// stores aren't capable of handling multiple users, however it is + /// valid to use the same path for both stores on a single session. + #[deprecated = "Use `ClientBuilder::session_store_with_sqlite` instead"] + pub fn session_paths(self: Arc, data_path: String, cache_path: String) -> Arc { + let mut builder = unwrap_or_clone_arc(self); + builder.store = + Some(StoreBuilder::Sqlite(store::SqliteStoreBuilder::raw_new(data_path, cache_path))); + Arc::new(builder) + } } #[cfg(feature = "indexeddb")] diff --git a/bindings/matrix-sdk-ffi/src/store.rs b/bindings/matrix-sdk-ffi/src/store.rs index 72e2343c1..5ac81a0ac 100644 --- a/bindings/matrix-sdk-ffi/src/store.rs +++ b/bindings/matrix-sdk-ffi/src/store.rs @@ -56,6 +56,19 @@ mod sqlite { system_is_memory_constrained: bool, } + impl SqliteStoreBuilder { + pub(crate) fn raw_new(data_path: String, cache_path: String) -> Self { + Self { + paths: StorePaths { data_path, cache_path }, + passphrase: Zeroizing::new(None), + pool_max_size: None, + cache_size: None, + journal_size_limit: None, + system_is_memory_constrained: false, + } + } + } + #[matrix_sdk_ffi_macros::export] impl SqliteStoreBuilder { /// Construct a [`SqliteStoreBuilder`] and set the paths that the client @@ -66,14 +79,7 @@ mod sqlite { /// same path for both stores on a single session. #[uniffi::constructor] pub fn new(data_path: String, cache_path: String) -> Arc { - Arc::new(Self { - paths: SessionPaths { data_path, cache_path }, - passphrase: Zeroizing::new(None), - pool_max_size: None, - cache_size: None, - journal_size_limit: None, - system_is_memory_constrained: false, - }) + Arc::new(Self::raw_new(data_path, cache_path)) } /// Set the passphrase for the stores.