diff --git a/matrix_sdk_crypto/src/device.rs b/matrix_sdk_crypto/src/device.rs index e2f9f764..fa93ace5 100644 --- a/matrix_sdk_crypto/src/device.rs +++ b/matrix_sdk_crypto/src/device.rs @@ -36,7 +36,7 @@ use serde_json::{json, Value}; use super::{Account, OlmMachine}; use crate::{ - error::SignatureError, verification::VerificationMachine, verify_json, Sas, UserDevices, + error::SignatureError, verification::VerificationMachine, verify_json, ReadOnlyUserDevices, Sas, }; /// A read-only version of a `Device`. @@ -79,7 +79,7 @@ impl Device { /// A read only view over all devices belonging to a user. #[derive(Debug)] pub struct UserDevicesWrap { - pub(crate) inner: UserDevices, + pub(crate) inner: ReadOnlyUserDevices, pub(crate) verification_machine: VerificationMachine, } diff --git a/matrix_sdk_crypto/src/lib.rs b/matrix_sdk_crypto/src/lib.rs index 933db0ef..00320efb 100644 --- a/matrix_sdk_crypto/src/lib.rs +++ b/matrix_sdk_crypto/src/lib.rs @@ -40,7 +40,7 @@ mod verification; pub use device::{Device, ReadOnlyDevice, TrustState, UserDevicesWrap}; pub use error::{MegolmError, OlmError}; pub use machine::{OlmMachine, OneTimeKeys}; -pub use memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}; +pub use memory_stores::{DeviceStore, GroupSessionStore, ReadOnlyUserDevices, SessionStore}; pub use olm::{ Account, EncryptionSettings, IdentityKeys, InboundGroupSession, OutboundGroupSession, Session, }; diff --git a/matrix_sdk_crypto/src/memory_stores.rs b/matrix_sdk_crypto/src/memory_stores.rs index 19a3fad6..380ac173 100644 --- a/matrix_sdk_crypto/src/memory_stores.rs +++ b/matrix_sdk_crypto/src/memory_stores.rs @@ -139,11 +139,11 @@ pub struct DeviceStore { /// A read only view over all devices belonging to a user. #[derive(Debug)] -pub struct UserDevices { +pub struct ReadOnlyUserDevices { entries: ReadOnlyView, ReadOnlyDevice>, } -impl UserDevices { +impl ReadOnlyUserDevices { /// Get the specific device with the given device id. pub fn get(&self, device_id: &DeviceId) -> Option { self.entries.get(device_id).cloned() @@ -202,11 +202,11 @@ impl DeviceStore { } /// Get a read-only view over all devices of the given user. - pub fn user_devices(&self, user_id: &UserId) -> UserDevices { + pub fn user_devices(&self, user_id: &UserId) -> ReadOnlyUserDevices { if !self.entries.contains_key(user_id) { self.entries.insert(user_id.clone(), DashMap::new()); } - UserDevices { + ReadOnlyUserDevices { entries: self.entries.get(user_id).unwrap().clone().into_read_only(), } } diff --git a/matrix_sdk_crypto/src/store/memorystore.rs b/matrix_sdk_crypto/src/store/memorystore.rs index 151dc0f9..660b3e90 100644 --- a/matrix_sdk_crypto/src/store/memorystore.rs +++ b/matrix_sdk_crypto/src/store/memorystore.rs @@ -24,7 +24,7 @@ use matrix_sdk_common::{ use super::{Account, CryptoStore, InboundGroupSession, Result, Session}; use crate::{ device::ReadOnlyDevice, - memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}, + memory_stores::{DeviceStore, GroupSessionStore, ReadOnlyUserDevices, SessionStore}, }; #[derive(Debug, Clone)] pub struct MemoryStore { @@ -120,7 +120,7 @@ impl CryptoStore for MemoryStore { Ok(()) } - async fn get_user_devices(&self, user_id: &UserId) -> Result { + async fn get_user_devices(&self, user_id: &UserId) -> Result { Ok(self.devices.user_devices(user_id)) } diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index 991a39ed..5e01d8a1 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -28,7 +28,7 @@ use url::ParseError; use super::{ device::ReadOnlyDevice, - memory_stores::UserDevices, + memory_stores::ReadOnlyUserDevices, olm::{Account, InboundGroupSession, Session}, }; @@ -196,5 +196,5 @@ pub trait CryptoStore: Debug { /// # Arguments /// /// * `user_id` - The user for which we should get all the devices. - async fn get_user_devices(&self, user_id: &UserId) -> Result; + async fn get_user_devices(&self, user_id: &UserId) -> Result; } diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index 10079b05..1946a376 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -37,7 +37,7 @@ use zeroize::Zeroizing; use super::{CryptoStore, CryptoStoreError, Result}; use crate::{ device::{ReadOnlyDevice, TrustState}, - memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}, + memory_stores::{DeviceStore, GroupSessionStore, ReadOnlyUserDevices, SessionStore}, Account, IdentityKeys, InboundGroupSession, Session, }; @@ -880,7 +880,7 @@ impl CryptoStore for SqliteStore { Ok(self.devices.get(user_id, device_id)) } - async fn get_user_devices(&self, user_id: &UserId) -> Result { + async fn get_user_devices(&self, user_id: &UserId) -> Result { Ok(self.devices.user_devices(user_id)) } }