crypto: Rename UserDevices to ReadOnlyUserDevices.
parent
8aedc3077d
commit
de097d3ca0
|
@ -36,7 +36,7 @@ use serde_json::{json, Value};
|
||||||
use super::{Account, OlmMachine};
|
use super::{Account, OlmMachine};
|
||||||
|
|
||||||
use crate::{
|
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`.
|
/// A read-only version of a `Device`.
|
||||||
|
@ -79,7 +79,7 @@ impl Device {
|
||||||
/// A read only view over all devices belonging to a user.
|
/// A read only view over all devices belonging to a user.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct UserDevicesWrap {
|
pub struct UserDevicesWrap {
|
||||||
pub(crate) inner: UserDevices,
|
pub(crate) inner: ReadOnlyUserDevices,
|
||||||
pub(crate) verification_machine: VerificationMachine,
|
pub(crate) verification_machine: VerificationMachine,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ mod verification;
|
||||||
pub use device::{Device, ReadOnlyDevice, TrustState, UserDevicesWrap};
|
pub use device::{Device, ReadOnlyDevice, TrustState, UserDevicesWrap};
|
||||||
pub use error::{MegolmError, OlmError};
|
pub use error::{MegolmError, OlmError};
|
||||||
pub use machine::{OlmMachine, OneTimeKeys};
|
pub use machine::{OlmMachine, OneTimeKeys};
|
||||||
pub use memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
|
pub use memory_stores::{DeviceStore, GroupSessionStore, ReadOnlyUserDevices, SessionStore};
|
||||||
pub use olm::{
|
pub use olm::{
|
||||||
Account, EncryptionSettings, IdentityKeys, InboundGroupSession, OutboundGroupSession, Session,
|
Account, EncryptionSettings, IdentityKeys, InboundGroupSession, OutboundGroupSession, Session,
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,11 +139,11 @@ pub struct DeviceStore {
|
||||||
|
|
||||||
/// A read only view over all devices belonging to a user.
|
/// A read only view over all devices belonging to a user.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct UserDevices {
|
pub struct ReadOnlyUserDevices {
|
||||||
entries: ReadOnlyView<Box<DeviceId>, ReadOnlyDevice>,
|
entries: ReadOnlyView<Box<DeviceId>, ReadOnlyDevice>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserDevices {
|
impl ReadOnlyUserDevices {
|
||||||
/// Get the specific device with the given device id.
|
/// Get the specific device with the given device id.
|
||||||
pub fn get(&self, device_id: &DeviceId) -> Option<ReadOnlyDevice> {
|
pub fn get(&self, device_id: &DeviceId) -> Option<ReadOnlyDevice> {
|
||||||
self.entries.get(device_id).cloned()
|
self.entries.get(device_id).cloned()
|
||||||
|
@ -202,11 +202,11 @@ impl DeviceStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a read-only view over all devices of the given user.
|
/// 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) {
|
if !self.entries.contains_key(user_id) {
|
||||||
self.entries.insert(user_id.clone(), DashMap::new());
|
self.entries.insert(user_id.clone(), DashMap::new());
|
||||||
}
|
}
|
||||||
UserDevices {
|
ReadOnlyUserDevices {
|
||||||
entries: self.entries.get(user_id).unwrap().clone().into_read_only(),
|
entries: self.entries.get(user_id).unwrap().clone().into_read_only(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ use matrix_sdk_common::{
|
||||||
use super::{Account, CryptoStore, InboundGroupSession, Result, Session};
|
use super::{Account, CryptoStore, InboundGroupSession, Result, Session};
|
||||||
use crate::{
|
use crate::{
|
||||||
device::ReadOnlyDevice,
|
device::ReadOnlyDevice,
|
||||||
memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices},
|
memory_stores::{DeviceStore, GroupSessionStore, ReadOnlyUserDevices, SessionStore},
|
||||||
};
|
};
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct MemoryStore {
|
pub struct MemoryStore {
|
||||||
|
@ -120,7 +120,7 @@ impl CryptoStore for MemoryStore {
|
||||||
Ok(())
|
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))
|
Ok(self.devices.user_devices(user_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ use url::ParseError;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
device::ReadOnlyDevice,
|
device::ReadOnlyDevice,
|
||||||
memory_stores::UserDevices,
|
memory_stores::ReadOnlyUserDevices,
|
||||||
olm::{Account, InboundGroupSession, Session},
|
olm::{Account, InboundGroupSession, Session},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -196,5 +196,5 @@ pub trait CryptoStore: Debug {
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `user_id` - The user for which we should get all the devices.
|
/// * `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>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ use zeroize::Zeroizing;
|
||||||
use super::{CryptoStore, CryptoStoreError, Result};
|
use super::{CryptoStore, CryptoStoreError, Result};
|
||||||
use crate::{
|
use crate::{
|
||||||
device::{ReadOnlyDevice, TrustState},
|
device::{ReadOnlyDevice, TrustState},
|
||||||
memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices},
|
memory_stores::{DeviceStore, GroupSessionStore, ReadOnlyUserDevices, SessionStore},
|
||||||
Account, IdentityKeys, InboundGroupSession, Session,
|
Account, IdentityKeys, InboundGroupSession, Session,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -880,7 +880,7 @@ impl CryptoStore for SqliteStore {
|
||||||
Ok(self.devices.get(user_id, device_id))
|
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))
|
Ok(self.devices.user_devices(user_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue