Fix clippy lint rc_buffer
parent
27ecab8574
commit
0422bae924
|
@ -54,7 +54,7 @@ use crate::{
|
|||
pub struct ReadOnlyDevice {
|
||||
user_id: Arc<UserId>,
|
||||
device_id: Arc<Box<DeviceId>>,
|
||||
algorithms: Arc<Vec<EventEncryptionAlgorithm>>,
|
||||
algorithms: Arc<[EventEncryptionAlgorithm]>,
|
||||
keys: Arc<BTreeMap<DeviceKeyId, String>>,
|
||||
signatures: Arc<BTreeMap<UserId, BTreeMap<DeviceKeyId, String>>>,
|
||||
display_name: Arc<Option<String>>,
|
||||
|
@ -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()),
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -56,8 +56,8 @@ use crate::error::{EventError, MegolmResult};
|
|||
#[derive(Clone)]
|
||||
pub struct InboundGroupSession {
|
||||
inner: Arc<Mutex<OlmInboundGroupSession>>,
|
||||
session_id: Arc<String>,
|
||||
pub(crate) sender_key: Arc<String>,
|
||||
session_id: Arc<str>,
|
||||
pub(crate) sender_key: Arc<str>,
|
||||
pub(crate) signing_key: Arc<BTreeMap<DeviceKeyAlgorithm, String>>,
|
||||
pub(crate) room_id: Arc<RoomId>,
|
||||
forwarding_chains: Arc<Mutex<Option<Vec<String>>>>,
|
||||
|
@ -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<ExportedRoomKey> 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)),
|
||||
|
|
|
@ -99,7 +99,7 @@ pub struct OutboundGroupSession {
|
|||
inner: Arc<Mutex<OlmOutboundGroupSession>>,
|
||||
device_id: Arc<DeviceIdBox>,
|
||||
account_identity_keys: Arc<IdentityKeys>,
|
||||
session_id: Arc<String>,
|
||||
session_id: Arc<str>,
|
||||
room_id: Arc<RoomId>,
|
||||
pub(crate) creation_time: Arc<Instant>,
|
||||
message_count: Arc<AtomicU64>,
|
||||
|
@ -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)),
|
||||
|
|
|
@ -46,8 +46,8 @@ pub struct Session {
|
|||
pub(crate) device_id: Arc<Box<DeviceId>>,
|
||||
pub(crate) our_identity_keys: Arc<IdentityKeys>,
|
||||
pub(crate) inner: Arc<Mutex<OlmSession>>,
|
||||
pub(crate) session_id: Arc<String>,
|
||||
pub(crate) sender_key: Arc<String>,
|
||||
pub(crate) session_id: Arc<str>,
|
||||
pub(crate) sender_key: Arc<str>,
|
||||
pub(crate) creation_time: Arc<Instant>,
|
||||
pub(crate) last_use_time: Arc<Instant>,
|
||||
}
|
||||
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -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<UserId>,
|
||||
device_id: Arc<Box<DeviceId>>,
|
||||
account_info: Arc<SyncMutex<Option<AccountInfo>>>,
|
||||
path: Arc<PathBuf>,
|
||||
path: Arc<Path>,
|
||||
|
||||
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()),
|
||||
|
|
|
@ -51,7 +51,7 @@ pub struct Sas {
|
|||
account: ReadOnlyAccount,
|
||||
other_device: ReadOnlyDevice,
|
||||
other_identity: Option<UserIdentities>,
|
||||
flow_id: Arc<String>,
|
||||
flow_id: Arc<str>,
|
||||
}
|
||||
|
||||
impl Sas {
|
||||
|
@ -399,11 +399,11 @@ impl Sas {
|
|||
content
|
||||
}
|
||||
|
||||
pub(crate) fn verified_devices(&self) -> Option<Arc<Vec<ReadOnlyDevice>>> {
|
||||
pub(crate) fn verified_devices(&self) -> Option<Arc<[ReadOnlyDevice]>> {
|
||||
self.inner.lock().unwrap().verified_devices()
|
||||
}
|
||||
|
||||
pub(crate) fn verified_identities(&self) -> Option<Arc<Vec<UserIdentities>>> {
|
||||
pub(crate) fn verified_identities(&self) -> Option<Arc<[UserIdentities]>> {
|
||||
self.inner.lock().unwrap().verified_identities()
|
||||
}
|
||||
|
||||
|
@ -598,7 +598,7 @@ impl InnerSas {
|
|||
}
|
||||
}
|
||||
|
||||
fn verification_flow_id(&self) -> Arc<String> {
|
||||
fn verification_flow_id(&self) -> Arc<str> {
|
||||
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<Arc<Vec<ReadOnlyDevice>>> {
|
||||
fn verified_devices(&self) -> Option<Arc<[ReadOnlyDevice]>> {
|
||||
if let InnerSas::Done(s) = self {
|
||||
Some(s.verified_devices())
|
||||
} else {
|
||||
|
@ -635,7 +635,7 @@ impl InnerSas {
|
|||
}
|
||||
}
|
||||
|
||||
fn verified_identities(&self) -> Option<Arc<Vec<UserIdentities>>> {
|
||||
fn verified_identities(&self) -> Option<Arc<[UserIdentities]>> {
|
||||
if let InnerSas::Done(s) = self {
|
||||
Some(s.verified_identities())
|
||||
} else {
|
||||
|
|
|
@ -144,7 +144,7 @@ pub struct SasState<S: Clone> {
|
|||
///
|
||||
/// This will be the transaction id for to-device events and the relates_to
|
||||
/// field for in-room events.
|
||||
pub verification_flow_id: Arc<String>,
|
||||
pub verification_flow_id: Arc<str>,
|
||||
|
||||
/// The SAS state we're in.
|
||||
state: Arc<S>,
|
||||
|
@ -209,8 +209,8 @@ pub struct Confirmed {
|
|||
pub struct MacReceived {
|
||||
we_started: bool,
|
||||
their_pubkey: String,
|
||||
verified_devices: Arc<Vec<ReadOnlyDevice>>,
|
||||
verified_master_keys: Arc<Vec<UserIdentities>>,
|
||||
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<Vec<ReadOnlyDevice>>,
|
||||
verified_master_keys: Arc<Vec<UserIdentities>>,
|
||||
verified_devices: Arc<[ReadOnlyDevice]>,
|
||||
verified_master_keys: Arc<[UserIdentities]>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -269,7 +269,7 @@ impl<S: Clone> SasState<S> {
|
|||
}
|
||||
|
||||
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<Created> {
|
|||
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<Started> {
|
|||
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<Started> {
|
|||
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<KeyReceived> {
|
|||
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<Confirmed> {
|
|||
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<Done> {
|
|||
}
|
||||
|
||||
/// Get the list of verified devices.
|
||||
pub fn verified_devices(&self) -> Arc<Vec<ReadOnlyDevice>> {
|
||||
pub fn verified_devices(&self) -> Arc<[ReadOnlyDevice]> {
|
||||
self.state.verified_devices.clone()
|
||||
}
|
||||
|
||||
/// Get the list of verified identities.
|
||||
pub fn verified_identities(&self) -> Arc<Vec<UserIdentities>> {
|
||||
pub fn verified_identities(&self) -> Arc<[UserIdentities]> {
|
||||
self.state.verified_master_keys.clone()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue