dbus-settings-bindings/networkmanager/src/device/bluetooth.rs
2024-05-16 21:24:53 +02:00

33 lines
756 B
Rust

// SPDX-License-Identifier: MPL-2.0
use super::Device;
use crate::interface::device::{bluetooth::BluetoothDeviceProxy, DeviceProxy};
use std::ops::Deref;
use zbus::Result;
#[derive(Debug)]
pub struct BluetoothDevice<'a>(BluetoothDeviceProxy<'a>);
impl<'a> BluetoothDevice<'a> {
pub async fn upcast(&'a self) -> Result<Device<'a>> {
DeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await
.map(Device::from)
}
}
impl<'a> Deref for BluetoothDevice<'a> {
type Target = BluetoothDeviceProxy<'a>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'a> From<BluetoothDeviceProxy<'a>> for BluetoothDevice<'a> {
fn from(device: BluetoothDeviceProxy<'a>) -> Self {
BluetoothDevice(device)
}
}