Device can now be downcasted to a specific type of device (and upcasted back)
This commit is contained in:
parent
2acdb272fb
commit
e40c3e7787
7 changed files with 106 additions and 6 deletions
|
|
@ -1,10 +1,22 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::interface::device::bluetooth::BluetoothDeviceProxy;
|
||||
use super::Device;
|
||||
use crate::interface::device::{bluetooth::BluetoothDeviceProxy, DeviceProxy};
|
||||
use std::ops::Deref;
|
||||
use zbus::Result;
|
||||
|
||||
pub struct BluetoothDevice<'a>(BluetoothDeviceProxy<'a>);
|
||||
|
||||
impl<'a> BluetoothDevice<'a> {
|
||||
pub async fn upcast(&'a self) -> Result<Device<'a>> {
|
||||
DeviceProxy::builder(self.0.connection())
|
||||
.path(self.0.path())?
|
||||
.build()
|
||||
.await
|
||||
.map(Device::from)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Deref for BluetoothDevice<'a> {
|
||||
type Target = BluetoothDeviceProxy<'a>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::interface::device::wired::WiredDeviceProxy;
|
||||
use super::Device;
|
||||
use crate::interface::device::{wired::WiredDeviceProxy, DeviceProxy};
|
||||
use std::ops::Deref;
|
||||
use zbus::Result;
|
||||
|
||||
pub struct WiredDevice<'a>(WiredDeviceProxy<'a>);
|
||||
|
||||
impl<'a> WiredDevice<'a> {
|
||||
pub async fn upcast(&'a self) -> Result<Device<'a>> {
|
||||
DeviceProxy::builder(self.0.connection())
|
||||
.path(self.0.path())?
|
||||
.build()
|
||||
.await
|
||||
.map(Device::from)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Deref for WiredDevice<'a> {
|
||||
type Target = WiredDeviceProxy<'a>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,25 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::interface::{device::wireless::WirelessDeviceProxy, enums::WifiCapabilities};
|
||||
use super::Device;
|
||||
use crate::interface::{
|
||||
device::{wireless::WirelessDeviceProxy, DeviceProxy},
|
||||
enums::WifiCapabilities,
|
||||
};
|
||||
use std::ops::Deref;
|
||||
use zbus::Result;
|
||||
|
||||
pub struct WirelessDevice<'a>(WirelessDeviceProxy<'a>);
|
||||
|
||||
impl<'a> WirelessDevice<'a> {
|
||||
pub async fn upcast(&'a self) -> Result<Device<'a>> {
|
||||
DeviceProxy::builder(self.0.connection())
|
||||
.path(self.0.path())?
|
||||
.build()
|
||||
.await
|
||||
.map(Device::from)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> WirelessDevice<'a> {
|
||||
pub async fn wireless_capabilities(&self) -> Result<WifiCapabilities> {
|
||||
self.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue