crypto: Rename UserDevices to ReadOnlyUserDevices.

master
Damir Jelić 2020-08-17 17:01:38 +02:00
parent 8aedc3077d
commit de097d3ca0
6 changed files with 13 additions and 13 deletions

View File

@ -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,
}

View File

@ -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,
};

View File

@ -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<Box<DeviceId>, ReadOnlyDevice>,
}
impl UserDevices {
impl ReadOnlyUserDevices {
/// Get the specific device with the given device id.
pub fn get(&self, device_id: &DeviceId) -> Option<ReadOnlyDevice> {
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(),
}
}

View File

@ -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<UserDevices> {
async fn get_user_devices(&self, user_id: &UserId) -> Result<ReadOnlyUserDevices> {
Ok(self.devices.user_devices(user_id))
}

View File

@ -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<UserDevices>;
async fn get_user_devices(&self, user_id: &UserId) -> Result<ReadOnlyUserDevices>;
}

View File

@ -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<UserDevices> {
async fn get_user_devices(&self, user_id: &UserId) -> Result<ReadOnlyUserDevices> {
Ok(self.devices.user_devices(user_id))
}
}