dbus-settings-bindings/networkmanager/src/device/bluetooth.rs

34 lines
740 B
Rust
Raw Normal View History

2022-01-11 15:23:09 -05:00
// SPDX-License-Identifier: MPL-2.0
use super::Device;
use crate::interface::device::{bluetooth::BluetoothDeviceProxy, DeviceProxy};
2022-01-11 15:23:09 -05:00
use std::ops::Deref;
use zbus::Result;
2022-01-11 15:23:09 -05:00
2022-01-21 11:12:35 -05:00
#[derive(Debug)]
2022-01-11 15:23:09 -05:00
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)
}
}
2022-01-11 15:23:09 -05:00
impl<'a> Deref for BluetoothDevice<'a> {
type Target = BluetoothDeviceProxy<'a>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
2022-01-11 16:41:10 -05:00
impl<'a> From<BluetoothDeviceProxy<'a>> for BluetoothDevice<'a> {
fn from(device: BluetoothDeviceProxy<'a>) -> Self {
BluetoothDevice(device)
}
}