2022-01-11 15:23:09 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2022-01-11 17:51:15 -05:00
|
|
|
use super::Device;
|
|
|
|
|
use crate::interface::{
|
|
|
|
|
device::{wireless::WirelessDeviceProxy, DeviceProxy},
|
|
|
|
|
enums::WifiCapabilities,
|
|
|
|
|
};
|
2022-01-11 15:23:09 -05:00
|
|
|
use std::ops::Deref;
|
2022-01-11 16:41:10 -05:00
|
|
|
use zbus::Result;
|
2022-01-11 15:23:09 -05:00
|
|
|
|
|
|
|
|
pub struct WirelessDevice<'a>(WirelessDeviceProxy<'a>);
|
|
|
|
|
|
2022-01-11 17:51:15 -05:00
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-11 16:41:10 -05:00
|
|
|
impl<'a> WirelessDevice<'a> {
|
|
|
|
|
pub async fn wireless_capabilities(&self) -> Result<WifiCapabilities> {
|
|
|
|
|
self.0
|
|
|
|
|
.wireless_capabilities()
|
|
|
|
|
.await
|
|
|
|
|
.map(WifiCapabilities::from_bits_truncate)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-11 15:23:09 -05:00
|
|
|
impl<'a> Deref for WirelessDevice<'a> {
|
|
|
|
|
type Target = WirelessDeviceProxy<'a>;
|
|
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
|
&self.0
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-11 16:41:10 -05:00
|
|
|
|
|
|
|
|
impl<'a> From<WirelessDeviceProxy<'a>> for WirelessDevice<'a> {
|
|
|
|
|
fn from(device: WirelessDeviceProxy<'a>) -> Self {
|
|
|
|
|
WirelessDevice(device)
|
|
|
|
|
}
|
|
|
|
|
}
|