crypto: Rename DeviceWrap to Device.

This commit is contained in:
Damir Jelić 2020-08-17 16:36:50 +02:00
parent 43aea6e482
commit 91db502cfe
6 changed files with 16 additions and 16 deletions

View file

@ -14,7 +14,7 @@
use std::ops::Deref;
use matrix_sdk_base::{DeviceWrap, ReadOnlyDevice, UserDevicesWrap};
use matrix_sdk_base::{Device as BaseDevice, ReadOnlyDevice, UserDevicesWrap};
use matrix_sdk_common::{
api::r0::to_device::send_event_to_device::Request as ToDeviceRequest, identifiers::DeviceId,
};
@ -24,7 +24,7 @@ use crate::{error::Result, http_client::HttpClient, Sas};
#[derive(Clone, Debug)]
/// A device represents a E2EE capable client of an user.
pub struct Device {
pub(crate) inner: DeviceWrap,
pub(crate) inner: BaseDevice,
pub(crate) http_client: HttpClient,
}

View file

@ -53,7 +53,7 @@ use matrix_sdk_common::{
};
#[cfg(feature = "encryption")]
use matrix_sdk_crypto::{
CryptoStore, CryptoStoreError, DeviceWrap, OlmError, OlmMachine, Sas, UserDevicesWrap,
CryptoStore, CryptoStoreError, Device, OlmError, OlmMachine, Sas, UserDevicesWrap,
};
use zeroize::Zeroizing;
@ -1904,7 +1904,7 @@ impl BaseClient {
/// ```
#[cfg(feature = "encryption")]
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn get_device(&self, user_id: &UserId, device_id: &DeviceId) -> Option<DeviceWrap> {
pub async fn get_device(&self, user_id: &UserId, device_id: &DeviceId) -> Option<Device> {
let olm = self.olm.lock().await;
olm.as_ref()?.get_device(user_id, device_id).await
}

View file

@ -57,7 +57,7 @@ pub use state::{AllRooms, ClientState};
#[cfg(feature = "encryption")]
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub use matrix_sdk_crypto::{
CryptoStoreError, DeviceWrap, ReadOnlyDevice, Sas, TrustState, UserDevicesWrap,
CryptoStoreError, Device, ReadOnlyDevice, Sas, TrustState, UserDevicesWrap,
};
#[cfg(feature = "messages")]

View file

@ -54,12 +54,12 @@ pub struct ReadOnlyDevice {
#[derive(Debug, Clone)]
/// A device represents a E2EE capable client of an user.
pub struct DeviceWrap {
pub struct Device {
pub(crate) inner: ReadOnlyDevice,
pub(crate) verification_machine: VerificationMachine,
}
impl Deref for DeviceWrap {
impl Deref for Device {
type Target = ReadOnlyDevice;
fn deref(&self) -> &Self::Target {
@ -67,7 +67,7 @@ impl Deref for DeviceWrap {
}
}
impl DeviceWrap {
impl Device {
/// Start a interactive verification with this `Device`
///
/// Returns a `Sas` object and to-device request that needs to be sent out.
@ -85,8 +85,8 @@ pub struct UserDevicesWrap {
impl UserDevicesWrap {
/// Get the specific device with the given device id.
pub fn get(&self, device_id: &DeviceId) -> Option<DeviceWrap> {
self.inner.get(device_id).map(|d| DeviceWrap {
pub fn get(&self, device_id: &DeviceId) -> Option<Device> {
self.inner.get(device_id).map(|d| Device {
inner: d,
verification_machine: self.verification_machine.clone(),
})
@ -98,10 +98,10 @@ impl UserDevicesWrap {
}
/// Iterator over all the devices of the user devices.
pub fn devices(&self) -> impl Iterator<Item = DeviceWrap> + '_ {
pub fn devices(&self) -> impl Iterator<Item = Device> + '_ {
let machine = self.verification_machine.clone();
self.inner.devices().map(move |d| DeviceWrap {
self.inner.devices().map(move |d| Device {
inner: d.clone(),
verification_machine: machine.clone(),
})

View file

@ -37,7 +37,7 @@ mod store;
mod user_identity;
mod verification;
pub use device::{DeviceWrap, ReadOnlyDevice, TrustState, UserDevicesWrap};
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};

View file

@ -53,7 +53,7 @@ use matrix_sdk_common::{
#[cfg(feature = "sqlite_cryptostore")]
use super::store::sqlite::SqliteStore;
use super::{
device::{DeviceWrap, ReadOnlyDevice, UserDevicesWrap},
device::{Device, ReadOnlyDevice, UserDevicesWrap},
error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult},
olm::{
Account, EncryptionSettings, GroupSessionKey, IdentityKeys, InboundGroupSession,
@ -1330,7 +1330,7 @@ impl OlmMachine {
/// println!("{:?}", device);
/// # });
/// ```
pub async fn get_device(&self, user_id: &UserId, device_id: &DeviceId) -> Option<DeviceWrap> {
pub async fn get_device(&self, user_id: &UserId, device_id: &DeviceId) -> Option<Device> {
let device = self
.store
.get_device(user_id, device_id)
@ -1338,7 +1338,7 @@ impl OlmMachine {
.ok()
.flatten()?;
Some(DeviceWrap {
Some(Device {
inner: device,
verification_machine: self.verification_machine.clone(),
})