Skip to content

feat(wasm): add feature support for indexedb and sqlite to matrix-sdk-ffi #5245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bindings/matrix-sdk-ffi/src/client_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
helpers::unwrap_or_clone_arc,
qr_code::{HumanQrLoginError, QrCodeData, QrLoginProgressListener},
runtime::get_runtime_handle,
session_store::{SessionStoreConfig, SessionStoreResult},
session_store::{SessionStoreBuilder, SessionStoreResult},
task_handle::TaskHandle,
};

Expand Down Expand Up @@ -108,7 +108,7 @@ impl From<ClientError> for ClientBuildError {

#[derive(Clone, uniffi::Object)]
pub struct ClientBuilder {
session_store: Option<SessionStoreConfig>,
session_store: Option<SessionStoreBuilder>,
system_is_memory_constrained: bool,
username: Option<String>,
homeserver_cfg: Option<HomeserverConfig>,
Expand Down Expand Up @@ -554,7 +554,7 @@ impl ClientBuilder {
config: Arc<crate::session_store::SqliteSessionStoreBuilder>,
) -> Arc<Self> {
let mut builder = unwrap_or_clone_arc(self);
builder.session_store = Some(SessionStoreConfig::Sqlite(config.as_ref().clone()));
builder.session_store = Some(SessionStoreBuilder::Sqlite(config.as_ref().clone()));
Arc::new(builder)
}
}
Expand All @@ -568,7 +568,7 @@ impl ClientBuilder {
config: Arc<crate::session_store::IndexedDbSessionStoreBuilder>,
) -> Arc<Self> {
let mut builder = unwrap_or_clone_arc(self);
builder.session_store = Some(SessionStoreConfig::IndexedDb(config.as_ref().clone()));
builder.session_store = Some(SessionStoreBuilder::IndexedDb(config.as_ref().clone()));
Arc::new(builder)
}
}
Expand Down
14 changes: 7 additions & 7 deletions bindings/matrix-sdk-ffi/src/session_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;
#[cfg(feature = "sqlite")]
use matrix_sdk::SqliteStoreConfig;

/// The result of building a [`SessionStoreConfig`], with data that
/// The result of building a [`SessionStoreBuilder`], with data that
/// can be passed directly to a ClientBuilder.
pub enum SessionStoreResult {
#[cfg(feature = "sqlite")]
Expand Down Expand Up @@ -227,24 +227,24 @@ use crate::client_builder::ClientBuildError;

/// Represent the kind of store the client will configure.
#[derive(Clone)]
pub enum SessionStoreConfig {
pub enum SessionStoreBuilder {
/// Represents the builder for the SQLite store.
#[cfg(feature = "sqlite")]
/// Setup the client to use the SQLite store.
Sqlite(SqliteSessionStoreBuilder),

/// Represents the client for the IndexedDB store.
#[cfg(feature = "indexeddb")]
/// Setup the client to use the IndexedDB store.
IndexedDb(IndexedDbSessionStoreBuilder),
}

impl SessionStoreConfig {
impl SessionStoreBuilder {
pub(crate) fn build(&self) -> Result<SessionStoreResult, ClientBuildError> {
match self {
#[cfg(feature = "sqlite")]
SessionStoreConfig::Sqlite(config) => config.build(),
SessionStoreBuilder::Sqlite(config) => config.build(),

#[cfg(feature = "indexeddb")]
SessionStoreConfig::IndexedDb(config) => config.build(),
SessionStoreBuilder::IndexedDb(config) => config.build(),
}
}
}
Loading