From fe7f157253b6dcb668ffb3071ec392d87fea5d05 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 6 Oct 2022 22:43:42 +0200 Subject: [PATCH] refactor(bindings): Use UniFFI proc-macros for CrossSigningStatus --- bindings/matrix-sdk-crypto-ffi/src/lib.rs | 4 ++-- bindings/matrix-sdk-crypto-ffi/src/machine.rs | 19 +++++++++++-------- bindings/matrix-sdk-crypto-ffi/src/olm.udl | 7 ------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/src/lib.rs b/bindings/matrix-sdk-crypto-ffi/src/lib.rs index d15fd04be..a6fa482f8 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/lib.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/lib.rs @@ -484,7 +484,7 @@ pub struct DecryptedEvent { /// Struct representing the state of our private cross signing keys, it shows /// which private cross signing keys we have locally stored. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, uniffi::Record)] pub struct CrossSigningStatus { /// Do we have the master key. pub has_master: bool, @@ -602,7 +602,7 @@ mod uniffi_types { error::CryptoStoreError, machine::OlmMachine, responses::Request, - BackupKeys, RoomKeyCounts, + BackupKeys, CrossSigningStatus, RoomKeyCounts, }; } diff --git a/bindings/matrix-sdk-crypto-ffi/src/machine.rs b/bindings/matrix-sdk-crypto-ffi/src/machine.rs index 2855ccd39..b80d906ed 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/machine.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/machine.rs @@ -149,6 +149,17 @@ impl OlmMachine { } } +#[uniffi::export] +impl OlmMachine { + /// Get the status of the private cross signing keys. + /// + /// This can be used to check which private cross signing keys we have + /// stored locally. + pub fn cross_signing_status(&self) -> CrossSigningStatus { + self.runtime.block_on(self.inner.cross_signing_status()).into() + } +} + impl OlmMachine { /// Create a new `OlmMachine` /// @@ -1125,14 +1136,6 @@ impl OlmMachine { Ok(self.runtime.block_on(self.inner.bootstrap_cross_signing(true))?.into()) } - /// Get the status of the private cross signing keys. - /// - /// This can be used to check which private cross signing keys we have - /// stored locally. - pub fn cross_signing_status(&self) -> CrossSigningStatus { - self.runtime.block_on(self.inner.cross_signing_status()).into() - } - /// Export all our private cross signing keys. /// /// The export will contain the seed for the ed25519 keys as a base64 diff --git a/bindings/matrix-sdk-crypto-ffi/src/olm.udl b/bindings/matrix-sdk-crypto-ffi/src/olm.udl index 2ab938a67..5a3155755 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/olm.udl +++ b/bindings/matrix-sdk-crypto-ffi/src/olm.udl @@ -110,12 +110,6 @@ interface UserIdentity { ); }; -dictionary CrossSigningStatus { - boolean has_master; - boolean has_self_signing; - boolean has_user_signing; -}; - dictionary CrossSigningKeyExport { string? master_key; string? self_signing_key; @@ -449,7 +443,6 @@ interface OlmMachine { [Throws=CryptoStoreError] void discard_room_key([ByRef] string room_id); - CrossSigningStatus cross_signing_status(); [Throws=CryptoStoreError] BootstrapCrossSigningResult bootstrap_cross_signing(); CrossSigningKeyExport? export_cross_signing_keys();