crypto: Rename DeviceWrap to Device.
parent
43aea6e482
commit
91db502cfe
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use matrix_sdk_base::{DeviceWrap, ReadOnlyDevice, UserDevicesWrap};
|
use matrix_sdk_base::{Device as BaseDevice, ReadOnlyDevice, UserDevicesWrap};
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
api::r0::to_device::send_event_to_device::Request as ToDeviceRequest, identifiers::DeviceId,
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
/// A device represents a E2EE capable client of an user.
|
/// A device represents a E2EE capable client of an user.
|
||||||
pub struct Device {
|
pub struct Device {
|
||||||
pub(crate) inner: DeviceWrap,
|
pub(crate) inner: BaseDevice,
|
||||||
pub(crate) http_client: HttpClient,
|
pub(crate) http_client: HttpClient,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ use matrix_sdk_common::{
|
||||||
};
|
};
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
use matrix_sdk_crypto::{
|
use matrix_sdk_crypto::{
|
||||||
CryptoStore, CryptoStoreError, DeviceWrap, OlmError, OlmMachine, Sas, UserDevicesWrap,
|
CryptoStore, CryptoStoreError, Device, OlmError, OlmMachine, Sas, UserDevicesWrap,
|
||||||
};
|
};
|
||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
|
|
||||||
|
@ -1904,7 +1904,7 @@ impl BaseClient {
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
#[cfg_attr(feature = "docs", doc(cfg(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;
|
let olm = self.olm.lock().await;
|
||||||
olm.as_ref()?.get_device(user_id, device_id).await
|
olm.as_ref()?.get_device(user_id, device_id).await
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ pub use state::{AllRooms, ClientState};
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
|
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
|
||||||
pub use matrix_sdk_crypto::{
|
pub use matrix_sdk_crypto::{
|
||||||
CryptoStoreError, DeviceWrap, ReadOnlyDevice, Sas, TrustState, UserDevicesWrap,
|
CryptoStoreError, Device, ReadOnlyDevice, Sas, TrustState, UserDevicesWrap,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "messages")]
|
#[cfg(feature = "messages")]
|
||||||
|
|
|
@ -54,12 +54,12 @@ pub struct ReadOnlyDevice {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
/// A device represents a E2EE capable client of an user.
|
/// A device represents a E2EE capable client of an user.
|
||||||
pub struct DeviceWrap {
|
pub struct Device {
|
||||||
pub(crate) inner: ReadOnlyDevice,
|
pub(crate) inner: ReadOnlyDevice,
|
||||||
pub(crate) verification_machine: VerificationMachine,
|
pub(crate) verification_machine: VerificationMachine,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for DeviceWrap {
|
impl Deref for Device {
|
||||||
type Target = ReadOnlyDevice;
|
type Target = ReadOnlyDevice;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
@ -67,7 +67,7 @@ impl Deref for DeviceWrap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceWrap {
|
impl Device {
|
||||||
/// Start a interactive verification with this `Device`
|
/// Start a interactive verification with this `Device`
|
||||||
///
|
///
|
||||||
/// Returns a `Sas` object and to-device request that needs to be sent out.
|
/// Returns a `Sas` object and to-device request that needs to be sent out.
|
||||||
|
@ -85,8 +85,8 @@ pub struct UserDevicesWrap {
|
||||||
|
|
||||||
impl UserDevicesWrap {
|
impl UserDevicesWrap {
|
||||||
/// 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<DeviceWrap> {
|
pub fn get(&self, device_id: &DeviceId) -> Option<Device> {
|
||||||
self.inner.get(device_id).map(|d| DeviceWrap {
|
self.inner.get(device_id).map(|d| Device {
|
||||||
inner: d,
|
inner: d,
|
||||||
verification_machine: self.verification_machine.clone(),
|
verification_machine: self.verification_machine.clone(),
|
||||||
})
|
})
|
||||||
|
@ -98,10 +98,10 @@ impl UserDevicesWrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterator over all the devices of the user devices.
|
/// 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();
|
let machine = self.verification_machine.clone();
|
||||||
|
|
||||||
self.inner.devices().map(move |d| DeviceWrap {
|
self.inner.devices().map(move |d| Device {
|
||||||
inner: d.clone(),
|
inner: d.clone(),
|
||||||
verification_machine: machine.clone(),
|
verification_machine: machine.clone(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -37,7 +37,7 @@ mod store;
|
||||||
mod user_identity;
|
mod user_identity;
|
||||||
mod verification;
|
mod verification;
|
||||||
|
|
||||||
pub use device::{DeviceWrap, 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, SessionStore, UserDevices};
|
||||||
|
|
|
@ -53,7 +53,7 @@ use matrix_sdk_common::{
|
||||||
#[cfg(feature = "sqlite_cryptostore")]
|
#[cfg(feature = "sqlite_cryptostore")]
|
||||||
use super::store::sqlite::SqliteStore;
|
use super::store::sqlite::SqliteStore;
|
||||||
use super::{
|
use super::{
|
||||||
device::{DeviceWrap, ReadOnlyDevice, UserDevicesWrap},
|
device::{Device, ReadOnlyDevice, UserDevicesWrap},
|
||||||
error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult},
|
error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult},
|
||||||
olm::{
|
olm::{
|
||||||
Account, EncryptionSettings, GroupSessionKey, IdentityKeys, InboundGroupSession,
|
Account, EncryptionSettings, GroupSessionKey, IdentityKeys, InboundGroupSession,
|
||||||
|
@ -1330,7 +1330,7 @@ impl OlmMachine {
|
||||||
/// println!("{:?}", device);
|
/// 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
|
let device = self
|
||||||
.store
|
.store
|
||||||
.get_device(user_id, device_id)
|
.get_device(user_id, device_id)
|
||||||
|
@ -1338,7 +1338,7 @@ impl OlmMachine {
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()?;
|
.flatten()?;
|
||||||
|
|
||||||
Some(DeviceWrap {
|
Some(Device {
|
||||||
inner: device,
|
inner: device,
|
||||||
verification_machine: self.verification_machine.clone(),
|
verification_machine: self.verification_machine.clone(),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue