Skip to content

Commit

Permalink
fixup: Avoid copying an enum and conditionally derive uniffi::Enum in…
Browse files Browse the repository at this point in the history
…stead
  • Loading branch information
andybalaam committed Apr 15, 2024
1 parent cf35c38 commit 71c6878
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
40 changes: 1 addition & 39 deletions bindings/matrix-sdk-ffi/src/client_builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fs, path::PathBuf, sync::Arc};

use matrix_sdk::{
encryption::EncryptionSettings,
encryption::{BackupDownloadStrategy, EncryptionSettings},
reqwest::Certificate,
ruma::{
api::{error::UnknownVersionError, MatrixVersion},
Expand All @@ -27,44 +27,6 @@ enum HomeserverConfig {
ServerNameOrUrl(String),
}

#[derive(uniffi::Enum)]
pub enum BackupDownloadStrategy {
/// Automatically download all room keys from the backup when the backup
/// recovery key has been received. The backup recovery key can be received
/// in two ways:
///
/// 1. Received as a `m.secret.send` to-device event, after a successful
/// interactive verification.
/// 2. Imported from secret storage (4S) using the
/// [`SecretStore::import_secrets()`] method.
///
/// [`SecretStore::import_secrets()`]: crate::encryption::secret_storage::SecretStore::import_secrets
OneShot,

/// Attempt to download a single room key if an event fails to be decrypted.
AfterDecryptionFailure,

/// Don't download any room keys automatically. The user can manually
/// download room keys using the [`Backups::download_room_key()`] methods.
Manual,
}

impl From<BackupDownloadStrategy> for matrix_sdk::encryption::BackupDownloadStrategy {
fn from(strategy: BackupDownloadStrategy) -> Self {
match strategy {
BackupDownloadStrategy::OneShot => {
matrix_sdk::encryption::BackupDownloadStrategy::OneShot
}
BackupDownloadStrategy::AfterDecryptionFailure => {
matrix_sdk::encryption::BackupDownloadStrategy::AfterDecryptionFailure
}
BackupDownloadStrategy::Manual => {
matrix_sdk::encryption::BackupDownloadStrategy::Manual
}
}
}
}

#[derive(Debug, thiserror::Error, uniffi::Error)]
#[uniffi(flat_error)]
pub enum ClientBuildError {
Expand Down
1 change: 1 addition & 0 deletions crates/matrix-sdk/src/encryption/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ pub struct EncryptionSettings {

/// Settings for end-to-end encryption features.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
pub enum BackupDownloadStrategy {
/// Automatically download all room keys from the backup when the backup
/// recovery key has been received. The backup recovery key can be received
Expand Down

0 comments on commit 71c6878

Please sign in to comment.