matrix-sdk: Implement deref for our device wrapper.

master
Damir Jelić 2020-08-17 15:54:54 +02:00
parent fd8377bce2
commit 94248523b3
2 changed files with 17 additions and 4 deletions

View File

@ -1450,7 +1450,7 @@ impl Client {
///
/// # Example
///
/// ```
/// ```no_run
/// # use std::convert::TryFrom;
/// # use matrix_sdk::{Client, identifiers::UserId};
/// # use url::Url;
@ -1459,9 +1459,12 @@ impl Client {
/// # let homeserver = Url::parse("http://example.com").unwrap();
/// # let client = Client::new(homeserver).unwrap();
/// # block_on(async {
/// let device = client.get_device(&alice, "DEVICEID".into()).await;
/// let device = client.get_device(&alice, "DEVICEID".into()).await.unwrap();
///
/// println!("{:?}", device);
/// println!("{:?}", device.is_trusted());
///
///
/// let verification = device.start_verification().await.unwrap();
/// # });
/// ```
#[cfg(feature = "encryption")]

View File

@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use matrix_sdk_base::{DeviceWrap, UserDevicesWrap};
use std::ops::Deref;
use matrix_sdk_base::{Device as ReadOnlyDevice, DeviceWrap, UserDevicesWrap};
use matrix_sdk_common::{
api::r0::to_device::send_event_to_device::Request as ToDeviceRequest, identifiers::DeviceId,
};
@ -26,6 +28,14 @@ pub struct Device {
pub(crate) http_client: HttpClient,
}
impl Deref for Device {
type Target = ReadOnlyDevice;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl Device {
/// Start a interactive verification with this `Device`
///