From 0422bae92485b033d4f9b56f2331909653655609 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 25 Nov 2020 18:59:15 +0100 Subject: [PATCH] Fix clippy lint rc_buffer --- matrix_sdk_crypto/src/identities/device.rs | 8 ++--- matrix_sdk_crypto/src/olm/account.rs | 8 ++--- .../src/olm/group_sessions/inbound.rs | 20 ++++++------- .../src/olm/group_sessions/outbound.rs | 4 +-- matrix_sdk_crypto/src/olm/session.rs | 8 ++--- matrix_sdk_crypto/src/store/sqlite.rs | 6 ++-- matrix_sdk_crypto/src/verification/sas/mod.rs | 12 ++++---- .../src/verification/sas/sas_state.rs | 30 +++++++++---------- 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/matrix_sdk_crypto/src/identities/device.rs b/matrix_sdk_crypto/src/identities/device.rs index 73aeb22d..b9e8c8f2 100644 --- a/matrix_sdk_crypto/src/identities/device.rs +++ b/matrix_sdk_crypto/src/identities/device.rs @@ -54,7 +54,7 @@ use crate::{ pub struct ReadOnlyDevice { user_id: Arc, device_id: Arc>, - algorithms: Arc>, + algorithms: Arc<[EventEncryptionAlgorithm]>, keys: Arc>, signatures: Arc>>, display_name: Arc>, @@ -233,7 +233,7 @@ impl ReadOnlyDevice { display_name: Arc::new(display_name), trust_state: Arc::new(Atomic::new(trust_state)), signatures: Arc::new(signatures), - algorithms: Arc::new(algorithms), + algorithms: algorithms.into(), keys: Arc::new(keys), deleted: Arc::new(AtomicBool::new(false)), } @@ -396,7 +396,7 @@ impl ReadOnlyDevice { let display_name = Arc::new(device_keys.unsigned.device_display_name.clone()); - self.algorithms = Arc::new(device_keys.algorithms.clone()); + self.algorithms = device_keys.algorithms.as_slice().into(); self.keys = Arc::new(device_keys.keys.clone()); self.signatures = Arc::new(device_keys.signatures.clone()); self.display_name = display_name; @@ -467,7 +467,7 @@ impl TryFrom<&DeviceKeys> for ReadOnlyDevice { let device = Self { user_id: Arc::new(device_keys.user_id.clone()), device_id: Arc::new(device_keys.device_id.clone()), - algorithms: Arc::new(device_keys.algorithms.clone()), + algorithms: device_keys.algorithms.as_slice().into(), signatures: Arc::new(device_keys.signatures.clone()), keys: Arc::new(device_keys.keys.clone()), display_name: Arc::new(device_keys.unsigned.device_display_name.clone()), diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index c34cbdd7..c88b228f 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -746,8 +746,8 @@ impl ReadOnlyAccount { device_id: self.device_id.clone(), our_identity_keys: self.identity_keys.clone(), inner: Arc::new(Mutex::new(session)), - session_id: Arc::new(session_id), - sender_key: Arc::new(their_identity_key.to_owned()), + session_id: session_id.into(), + sender_key: their_identity_key.into(), creation_time: Arc::new(now), last_use_time: Arc::new(now), }) @@ -851,8 +851,8 @@ impl ReadOnlyAccount { device_id: self.device_id.clone(), our_identity_keys: self.identity_keys.clone(), inner: Arc::new(Mutex::new(session)), - session_id: Arc::new(session_id), - sender_key: Arc::new(their_identity_key.to_owned()), + session_id: session_id.into(), + sender_key: their_identity_key.into(), creation_time: Arc::new(now), last_use_time: Arc::new(now), }) diff --git a/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs b/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs index 9e8a5c11..a7249563 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs @@ -56,8 +56,8 @@ use crate::error::{EventError, MegolmResult}; #[derive(Clone)] pub struct InboundGroupSession { inner: Arc>, - session_id: Arc, - pub(crate) sender_key: Arc, + session_id: Arc, + pub(crate) sender_key: Arc, pub(crate) signing_key: Arc>, pub(crate) room_id: Arc, forwarding_chains: Arc>>>, @@ -95,8 +95,8 @@ impl InboundGroupSession { Ok(InboundGroupSession { inner: Arc::new(Mutex::new(session)), - session_id: Arc::new(session_id), - sender_key: Arc::new(sender_key.to_owned()), + session_id: session_id.into(), + sender_key: sender_key.to_owned().into(), signing_key: Arc::new(keys), room_id: Arc::new(room_id.clone()), forwarding_chains: Arc::new(Mutex::new(None)), @@ -145,8 +145,8 @@ impl InboundGroupSession { Ok(InboundGroupSession { inner: Arc::new(Mutex::new(session)), - session_id: Arc::new(content.session_id.clone()), - sender_key: Arc::new(content.sender_key.clone()), + session_id: content.session_id.as_str().into(), + sender_key: content.sender_key.as_str().into(), signing_key: Arc::new(sender_claimed_key), room_id: Arc::new(content.room_id.clone()), forwarding_chains: Arc::new(Mutex::new(Some(forwarding_chains))), @@ -225,8 +225,8 @@ impl InboundGroupSession { Ok(InboundGroupSession { inner: Arc::new(Mutex::new(session)), - session_id: Arc::new(session_id), - sender_key: Arc::new(pickle.sender_key), + session_id: session_id.into(), + sender_key: pickle.sender_key.into(), signing_key: Arc::new(pickle.signing_key), room_id: Arc::new(pickle.room_id), forwarding_chains: Arc::new(Mutex::new(pickle.forwarding_chains)), @@ -377,8 +377,8 @@ impl TryFrom for InboundGroupSession { Ok(InboundGroupSession { inner: Arc::new(Mutex::new(session)), - session_id: Arc::new(key.session_id), - sender_key: Arc::new(key.sender_key), + session_id: key.session_id.into(), + sender_key: key.sender_key.into(), signing_key: Arc::new(key.sender_claimed_keys), room_id: Arc::new(key.room_id), forwarding_chains: Arc::new(Mutex::new(forwarding_chains)), diff --git a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs index dce031ed..adecc4e1 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs @@ -99,7 +99,7 @@ pub struct OutboundGroupSession { inner: Arc>, device_id: Arc, account_identity_keys: Arc, - session_id: Arc, + session_id: Arc, room_id: Arc, pub(crate) creation_time: Arc, message_count: Arc, @@ -140,7 +140,7 @@ impl OutboundGroupSession { room_id: Arc::new(room_id.to_owned()), device_id, account_identity_keys: identity_keys, - session_id: Arc::new(session_id), + session_id: session_id.into(), creation_time: Arc::new(Instant::now()), message_count: Arc::new(AtomicU64::new(0)), shared: Arc::new(AtomicBool::new(false)), diff --git a/matrix_sdk_crypto/src/olm/session.rs b/matrix_sdk_crypto/src/olm/session.rs index f11cdc51..a68f8230 100644 --- a/matrix_sdk_crypto/src/olm/session.rs +++ b/matrix_sdk_crypto/src/olm/session.rs @@ -46,8 +46,8 @@ pub struct Session { pub(crate) device_id: Arc>, pub(crate) our_identity_keys: Arc, pub(crate) inner: Arc>, - pub(crate) session_id: Arc, - pub(crate) sender_key: Arc, + pub(crate) session_id: Arc, + pub(crate) sender_key: Arc, pub(crate) creation_time: Arc, pub(crate) last_use_time: Arc, } @@ -232,8 +232,8 @@ impl Session { device_id, our_identity_keys, inner: Arc::new(Mutex::new(session)), - session_id: Arc::new(session_id), - sender_key: Arc::new(pickle.sender_key), + session_id: session_id.into(), + sender_key: pickle.sender_key.into(), creation_time: Arc::new(creation_time), last_use_time: Arc::new(last_use_time), }) diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index fe67e2d6..f2497f0a 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -15,7 +15,7 @@ use std::{ collections::{BTreeMap, HashSet}, convert::TryFrom, - path::{Path, PathBuf}, + path::Path, result::Result as StdResult, sync::{Arc, Mutex as SyncMutex}, }; @@ -54,7 +54,7 @@ pub struct SqliteStore { user_id: Arc, device_id: Arc>, account_info: Arc>>, - path: Arc, + path: Arc, sessions: SessionStore, inbound_group_sessions: GroupSessionStore, @@ -153,7 +153,7 @@ impl SqliteStore { sessions: SessionStore::new(), inbound_group_sessions: GroupSessionStore::new(), devices: DeviceStore::new(), - path: Arc::new(path.as_ref().to_owned()), + path: path.as_ref().into(), connection: Arc::new(Mutex::new(connection)), pickle_passphrase: Arc::new(passphrase), tracked_users: Arc::new(DashSet::new()), diff --git a/matrix_sdk_crypto/src/verification/sas/mod.rs b/matrix_sdk_crypto/src/verification/sas/mod.rs index 95d61541..9f823baa 100644 --- a/matrix_sdk_crypto/src/verification/sas/mod.rs +++ b/matrix_sdk_crypto/src/verification/sas/mod.rs @@ -51,7 +51,7 @@ pub struct Sas { account: ReadOnlyAccount, other_device: ReadOnlyDevice, other_identity: Option, - flow_id: Arc, + flow_id: Arc, } impl Sas { @@ -399,11 +399,11 @@ impl Sas { content } - pub(crate) fn verified_devices(&self) -> Option>> { + pub(crate) fn verified_devices(&self) -> Option> { self.inner.lock().unwrap().verified_devices() } - pub(crate) fn verified_identities(&self) -> Option>> { + pub(crate) fn verified_identities(&self) -> Option> { self.inner.lock().unwrap().verified_identities() } @@ -598,7 +598,7 @@ impl InnerSas { } } - fn verification_flow_id(&self) -> Arc { + fn verification_flow_id(&self) -> Arc { match self { InnerSas::Created(s) => s.verification_flow_id.clone(), InnerSas::Started(s) => s.verification_flow_id.clone(), @@ -627,7 +627,7 @@ impl InnerSas { } } - fn verified_devices(&self) -> Option>> { + fn verified_devices(&self) -> Option> { if let InnerSas::Done(s) = self { Some(s.verified_devices()) } else { @@ -635,7 +635,7 @@ impl InnerSas { } } - fn verified_identities(&self) -> Option>> { + fn verified_identities(&self) -> Option> { if let InnerSas::Done(s) = self { Some(s.verified_identities()) } else { diff --git a/matrix_sdk_crypto/src/verification/sas/sas_state.rs b/matrix_sdk_crypto/src/verification/sas/sas_state.rs index e934a07f..9c0ba30a 100644 --- a/matrix_sdk_crypto/src/verification/sas/sas_state.rs +++ b/matrix_sdk_crypto/src/verification/sas/sas_state.rs @@ -144,7 +144,7 @@ pub struct SasState { /// /// This will be the transaction id for to-device events and the relates_to /// field for in-room events. - pub verification_flow_id: Arc, + pub verification_flow_id: Arc, /// The SAS state we're in. state: Arc, @@ -209,8 +209,8 @@ pub struct Confirmed { pub struct MacReceived { we_started: bool, their_pubkey: String, - verified_devices: Arc>, - verified_master_keys: Arc>, + verified_devices: Arc<[ReadOnlyDevice]>, + verified_master_keys: Arc<[UserIdentities]>, } /// The SAS state indicating that the verification finished successfully. @@ -219,8 +219,8 @@ pub struct MacReceived { /// the master keys in the verified devices list. #[derive(Clone, Debug)] pub struct Done { - verified_devices: Arc>, - verified_master_keys: Arc>, + verified_devices: Arc<[ReadOnlyDevice]>, + verified_master_keys: Arc<[UserIdentities]>, } #[derive(Clone, Debug)] @@ -269,7 +269,7 @@ impl SasState { } fn check_event(&self, sender: &UserId, flow_id: &str) -> Result<(), CancelCode> { - if flow_id != *self.verification_flow_id { + if *flow_id != *self.verification_flow_id { Err(CancelCode::UnknownTransaction) } else if sender != self.ids.other_device.user_id() { Err(CancelCode::UserMismatch) @@ -303,7 +303,7 @@ impl SasState { other_device, other_identity, }, - verification_flow_id: Arc::new(verification_flow_id), + verification_flow_id: verification_flow_id.into(), creation_time: Arc::new(Instant::now()), last_event_time: Arc::new(Instant::now()), @@ -413,7 +413,7 @@ impl SasState { creation_time: Arc::new(Instant::now()), last_event_time: Arc::new(Instant::now()), - verification_flow_id: Arc::new(event.content.transaction_id.clone()), + verification_flow_id: event.content.transaction_id.as_str().into(), state: Arc::new(Started { protocol_definitions: content.clone(), @@ -452,7 +452,7 @@ impl SasState { other_identity, }, - verification_flow_id: Arc::new(event.content.transaction_id.clone()), + verification_flow_id: event.content.transaction_id.as_str().into(), state: Arc::new(Canceled::new(CancelCode::UnknownMethod)), }) } @@ -657,8 +657,8 @@ impl SasState { state: Arc::new(MacReceived { we_started: self.state.we_started, their_pubkey: self.state.their_pubkey.clone(), - verified_devices: Arc::new(devices), - verified_master_keys: Arc::new(master_keys), + verified_devices: devices.into(), + verified_master_keys: master_keys.into(), }), }) } @@ -712,8 +712,8 @@ impl SasState { ids: self.ids, state: Arc::new(Done { - verified_devices: Arc::new(devices), - verified_master_keys: Arc::new(master_keys), + verified_devices: devices.into(), + verified_master_keys: master_keys.into(), }), }) } @@ -792,12 +792,12 @@ impl SasState { } /// Get the list of verified devices. - pub fn verified_devices(&self) -> Arc> { + pub fn verified_devices(&self) -> Arc<[ReadOnlyDevice]> { self.state.verified_devices.clone() } /// Get the list of verified identities. - pub fn verified_identities(&self) -> Arc> { + pub fn verified_identities(&self) -> Arc<[UserIdentities]> { self.state.verified_master_keys.clone() } }