From e99341df69b53d71d4fd632023a7ce6e252539eb Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 6 Dec 2022 16:59:41 +0100 Subject: [PATCH] chore(bindings): Move bindings around to work around rustfmt bug --- bindings/matrix-sdk-crypto-ffi/src/machine.rs | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/src/machine.rs b/bindings/matrix-sdk-crypto-ffi/src/machine.rs index 7d307a2d6..4603262e7 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/machine.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/machine.rs @@ -156,30 +156,26 @@ impl OlmMachine { let device_id = device_id.into(); let runtime = Runtime::new().expect("Couldn't create a tokio runtime"); - let store = Arc::new( - runtime - .block_on(matrix_sdk_sled::SledCryptoStore::open(path, passphrase.as_deref())) - .map_err(|e| { - match e { - // This is a bit of an error in the sled store, the - // CryptoStore returns an `OpenStoreError` which has a - // variant for the state store. Not sure what to do about - // this. - matrix_sdk_sled::OpenStoreError::Crypto(r) => r.into(), - matrix_sdk_sled::OpenStoreError::Sled(s) => CryptoStoreError::CryptoStore( - matrix_sdk_crypto::store::CryptoStoreError::backend(s), - ), - _ => unreachable!(), - } - })?, - ); + let store = runtime + .block_on(matrix_sdk_sled::SledCryptoStore::open(path, passphrase.as_deref())) + .map_err(|e| match e { + // This is a bit of an error in the sled store, the + // CryptoStore returns an `OpenStoreError` which has a + // variant for the state store. Not sure what to do about + // this. + matrix_sdk_sled::OpenStoreError::Crypto(r) => r.into(), + matrix_sdk_sled::OpenStoreError::Sled(s) => CryptoStoreError::CryptoStore( + matrix_sdk_crypto::store::CryptoStoreError::backend(s), + ), + _ => unreachable!(), + })?; passphrase.zeroize(); - Ok(OlmMachine { - inner: runtime.block_on(InnerMachine::with_store(&user_id, device_id, store))?, - runtime, - }) + let inner = + runtime.block_on(InnerMachine::with_store(&user_id, device_id, Arc::new(store)))?; + + Ok(OlmMachine { inner, runtime }) } /// Get the display name of our own device.