feat: zbus 4.2.1 update

This commit is contained in:
Ashley Wulber 2024-05-16 15:24:53 -04:00 committed by GitHub
parent ce9c789fe6
commit f05789c4ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 390 additions and 389 deletions

View file

@ -18,5 +18,5 @@ futures-util = "0.3.30"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
time = { version = "0.3", features = ["parsing"] }
zbus = { version = "3.15.0" }
zvariant = { version = "3.15.0"}
zbus = { version = "4.2.1" }
zvariant = { version = "4.1.0"}

View file

@ -19,9 +19,9 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::{dbus_proxy, names::OwnedWellKnownName};
use zbus::{names::OwnedWellKnownName, proxy};
#[dbus_proxy(
#[proxy(
interface = "com.system76.CosmicSettingsDaemon",
default_service = "com.system76.CosmicSettingsDaemon",
default_path = "/com/system76/CosmicSettingsDaemon"
@ -54,22 +54,22 @@ trait CosmicSettingsDaemon {
) -> zbus::Result<(zbus::zvariant::OwnedObjectPath, OwnedWellKnownName)>;
/// DisplayBrightness property
#[dbus_proxy(property)]
#[zbus(property)]
fn display_brightness(&self) -> zbus::Result<i32>;
fn set_display_brightness(&self, value: i32) -> zbus::Result<()>;
/// KeyboardBrightness property
#[dbus_proxy(property)]
#[zbus(property)]
fn keyboard_brightness(&self) -> zbus::Result<i32>;
fn set_keyboard_brightness(&self, value: i32) -> zbus::Result<()>;
}
#[dbus_proxy(
#[proxy(
interface = "com.system76.CosmicSettingsDaemon.Config",
default_service = "com.system76.CosmicSettingsDaemon.Config"
)]
trait Config {
/// Changed signal
#[dbus_proxy(signal)]
#[zbus(signal)]
async fn changed(&self, id: String, key: String) -> zbus::Result<()>;
}

View file

@ -1,6 +1,6 @@
use serde_repr::{Deserialize_repr, Serialize_repr};
use zbus::{
dbus_proxy,
proxy,
zvariant::{ObjectPath, OwnedValue, Type},
Result,
};
@ -43,32 +43,32 @@ impl TryFrom<OwnedValue> for Accuracy {
}
}
#[dbus_proxy(
#[proxy(
default_service = "org.freedesktop.GeoClue2",
interface = "org.freedesktop.GeoClue2.Manager",
default_path = "/org/freedesktop/GeoClue2/Manager"
)]
trait Manager {
/// Retrieves a client object which can only be used by the calling application only. On the first call from a specific D-Bus peer, this method will create the client object but subsequent calls will return the path of the existing client.
#[dbus_proxy(object = "Client")]
#[zbus(object = "Client")]
fn get_client(&self);
/// Use this method to explicitly destroy a client, created using GetClient() or CreateClient().
///
/// Long-running applications, should either use this to delete associated client(s) when not needed, or disconnect from the D-Bus connection used for communicating with Geoclue (which is implicit on client process termination).
#[dbus_proxy(object = "Client")]
#[zbus(object = "Client")]
fn delete_client<'a>(&self, client: ObjectPath<'a>);
/// InUse property
#[dbus_proxy(property)]
#[zbus(property)]
fn in_use(&self) -> Result<bool>;
/// AvailableAccuracyLevel property
#[dbus_proxy(property)]
#[zbus(property)]
fn available_accuracy_level(&self) -> zbus::Result<Accuracy>;
}
#[dbus_proxy(
#[proxy(
default_service = "org.freedesktop.GeoClue2",
interface = "org.freedesktop.GeoClue2.Client"
)]
@ -80,7 +80,7 @@ trait Client {
fn stop(&self) -> zbus::Result<()>;
/// LocationUpdated signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn location_updated(
&self,
old: zbus::zvariant::ObjectPath<'_>,
@ -88,60 +88,60 @@ trait Client {
) -> zbus::Result<()>;
/// Active property
#[dbus_proxy(property)]
#[zbus(property)]
fn active(&self) -> zbus::Result<bool>;
/// DesktopId property
#[dbus_proxy(property)]
#[zbus(property)]
fn desktop_id(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_desktop_id(&self, value: &str) -> zbus::Result<()>;
/// DistanceThreshold property
#[dbus_proxy(property)]
#[zbus(property)]
fn distance_threshold(&self) -> zbus::Result<u32>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_distance_threshold(&self, value: u32) -> zbus::Result<()>;
/// Location property
#[dbus_proxy(property, object = "Location")]
#[zbus(property, object = "Location")]
fn location(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// RequestedAccuracyLevel property
#[dbus_proxy(property)]
#[zbus(property)]
fn requested_accuracy_level(&self) -> zbus::Result<Accuracy>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_requested_accuracy_level(&self, value: u32) -> zbus::Result<()>;
/// TimeThreshold property
#[dbus_proxy(property)]
#[zbus(property)]
fn time_threshold(&self) -> zbus::Result<u32>;
fn set_time_threshold(&self, value: u32) -> zbus::Result<()>;
}
#[dbus_proxy(
#[proxy(
default_service = "org.freedesktop.GeoClue2",
interface = "org.freedesktop.GeoClue2.Location"
)]
trait Location {
/// The latitude of the location, in degrees.
#[dbus_proxy(property)]
#[zbus(property)]
fn latitude(&self) -> Result<f64>;
/// The longitude of the location, in degrees.
#[dbus_proxy(property)]
#[zbus(property)]
fn longitude(&self) -> Result<f64>;
/// The accuracy of the location fix, in meters.
#[dbus_proxy(property)]
#[zbus(property)]
fn accuracy(&self) -> Result<f64>;
/// The altitude of the location fix, in meters.
/// When unknown, its set to minimum f64 value, -1.7976931348623157e+308.
#[dbus_proxy(property)]
#[zbus(property)]
fn altitude(&self) -> Result<f64>;
/// Speed in meters per second.
/// When unknown, it's set to -1.0.
#[dbus_proxy(property)]
#[zbus(property)]
fn speed(&self) -> Result<f64>;
/// The heading direction in degrees with respect to North direction, in clockwise order. That means North becomes 0 degree, East: 90 degrees, South: 180 degrees, West: 270 degrees and so on. When unknown, it's set to -1.0.
#[dbus_proxy(property)]
#[zbus(property)]
fn heading(&self) -> Result<f64>;
}

View file

@ -20,9 +20,9 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.mpris.MediaPlayer2",
default_path = "/org/mpris/MediaPlayer2"
)]
@ -34,30 +34,30 @@ trait MediaPlayer2 {
fn raise(&self) -> zbus::Result<()>;
/// CanQuit property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_quit(&self) -> zbus::Result<bool>;
/// CanRaise property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_raise(&self) -> zbus::Result<bool>;
/// DesktopEntry property
#[dbus_proxy(property)]
#[zbus(property)]
fn desktop_entry(&self) -> zbus::Result<String>;
/// HasTrackList property
#[dbus_proxy(property)]
#[zbus(property)]
fn has_track_list(&self) -> zbus::Result<bool>;
/// Identity property
#[dbus_proxy(property)]
#[zbus(property)]
fn identity(&self) -> zbus::Result<String>;
/// SupportedMimeTypes property
#[dbus_proxy(property)]
#[zbus(property)]
fn supported_mime_types(&self) -> zbus::Result<Vec<String>>;
/// SupportedUriSchemes property
#[dbus_proxy(property)]
#[zbus(property)]
fn supported_uri_schemes(&self) -> zbus::Result<Vec<String>>;
}

View file

@ -21,9 +21,9 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use crate::track::TrackId;
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.mpris.MediaPlayer2.Player",
default_path = "/org/mpris/MediaPlayer2"
)]
@ -56,76 +56,76 @@ trait Player {
fn stop(&self) -> zbus::Result<()>;
/// Seeked signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn seeked(&self, position: i64) -> zbus::Result<()>;
/// CanControl property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_control(&self) -> zbus::Result<bool>;
/// CanGoNext property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_go_next(&self) -> zbus::Result<bool>;
/// CanGoPrevious property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_go_previous(&self) -> zbus::Result<bool>;
/// CanPause property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_pause(&self) -> zbus::Result<bool>;
/// CanPlay property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_play(&self) -> zbus::Result<bool>;
/// CanSeek property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_seek(&self) -> zbus::Result<bool>;
/// MaximumRate property
#[dbus_proxy(property)]
#[zbus(property)]
fn maximum_rate(&self) -> zbus::Result<f64>;
/// Metadata property
#[dbus_proxy(property)]
#[zbus(property)]
fn metadata(
&self,
) -> zbus::Result<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>;
/// MinimumRate property
#[dbus_proxy(property)]
#[zbus(property)]
fn minimum_rate(&self) -> zbus::Result<f64>;
/// PlaybackStatus property
#[dbus_proxy(property)]
#[zbus(property)]
fn playback_status(&self) -> zbus::Result<String>;
/// Position property
#[dbus_proxy(property)]
#[zbus(property)]
fn position(&self) -> zbus::Result<i64>;
/// Rate property
#[dbus_proxy(property)]
#[zbus(property)]
fn rate(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_rate(&self, value: f64) -> zbus::Result<()>;
/// Shuffle property (optional)
#[dbus_proxy(property)]
#[zbus(property)]
fn shuffle(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_shuffle(&self, value: bool) -> zbus::Result<()>;
/// LoopStatus property (optional)
#[dbus_proxy(property)]
#[zbus(property)]
fn loop_status(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_loop_status(&self, value: String) -> zbus::Result<()>;
/// Volume property
#[dbus_proxy(property)]
#[zbus(property)]
fn volume(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_volume(&self, value: f64) -> zbus::Result<()>;
}

View file

@ -20,9 +20,9 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use crate::playlists::{id::PlaylistId, ordering::PlaylistOrdering, playlist::Playlist};
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.mpris.MediaPlayer2.Playlists",
default_path = "/org/mpris/MediaPlayer2"
)]
@ -40,18 +40,18 @@ trait Playlists {
) -> zbus::Result<Vec<Playlist>>;
/// PlaylistChanged signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn playlist_changed(&self, playlist: Playlist) -> zbus::Result<()>;
/// ActivePlaylist property
#[dbus_proxy(property)]
#[zbus(property)]
fn active_playlist(&self) -> zbus::Result<(bool, Playlist)>;
/// Orderings property
#[dbus_proxy(property)]
#[zbus(property)]
fn orderings(&self) -> zbus::Result<Vec<String>>;
/// PlaylistCount property
#[dbus_proxy(property)]
#[zbus(property)]
fn playlist_count(&self) -> zbus::Result<u32>;
}

View file

@ -20,9 +20,9 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use crate::track::TrackId;
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.mpris.MediaPlayer2.TrackList",
default_path = "/org/mpris/MediaPlayer2"
)]
@ -44,15 +44,15 @@ trait TrackList {
fn remove_track(&self, track_id: &TrackId) -> zbus::Result<()>;
/// TrackListReplaced signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn track_list_replaced(&self, tracks: Vec<TrackId>, current_track: TrackId)
-> zbus::Result<()>;
/// CanEditTracks property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_edit_tracks(&self) -> zbus::Result<bool>;
/// Tracks property
#[dbus_proxy(property)]
#[zbus(property)]
fn tracks(&self) -> zbus::Result<Vec<TrackId>>;
}

View file

@ -46,8 +46,8 @@ impl MediaPlayer {
/// Returns an instance to the `org.mpris.MediaPlayer2.Player` interface of this object.
pub async fn player(&self) -> Result<Player> {
PlayerProxy::builder(self.proxy.connection())
.destination(self.proxy.destination().to_owned())?
PlayerProxy::builder(self.proxy.inner().connection())
.destination(self.proxy.inner().destination().to_owned())?
.build()
.await
.map(Player::from)
@ -58,8 +58,8 @@ impl MediaPlayer {
/// if a track list is available.
pub async fn track_list(&self) -> Result<Option<TrackList>> {
if self.proxy.has_track_list().await? {
TrackListProxy::builder(self.proxy.connection())
.destination(self.proxy.destination().to_owned())?
TrackListProxy::builder(self.proxy.inner().connection())
.destination(self.proxy.inner().destination().to_owned())?
.build()
.await
.map(TrackList::from)
@ -74,8 +74,8 @@ impl MediaPlayer {
/// if a track list is available.
pub async fn playlists(&self) -> Result<Option<Playlists>> {
if self.proxy.has_track_list().await? {
PlaylistsProxy::builder(self.proxy.connection())
.destination(self.proxy.destination().to_owned())?
PlaylistsProxy::builder(self.proxy.inner().connection())
.destination(self.proxy.inner().destination().to_owned())?
.build()
.await
.map(Playlists::from)

View file

@ -448,27 +448,27 @@ impl MetadataValue {
impl<'a> From<&ZValue<'a>> for MetadataValue {
fn from(value: &ZValue) -> Self {
match value {
ZValue::U8(u) => Self::UInt(*u as u64),
ZValue::Bool(b) => Self::Bool(*b),
ZValue::I16(i) => Self::Int(*i as i64),
ZValue::U16(u) => Self::UInt(*u as u64),
ZValue::I32(i) => Self::Int(*i as i64),
ZValue::U32(u) => Self::UInt(*u as u64),
ZValue::I64(i) => Self::Int(*i),
ZValue::U64(u) => Self::UInt(*u),
ZValue::F64(f) => Self::Double(*f),
ZValue::Str(s) => Self::Str(s.to_string()),
ZValue::ObjectPath(path) => Self::Str(path.to_string()),
ZValue::Array(a) => Self::Array(a.iter().map(|v| v.into()).collect()),
ZValue::Dict(d) => Self::Dict(
HashMap::<String, ZValue>::try_from(d.to_owned())
match value.try_clone() {
Ok(ZValue::U8(u)) => Self::UInt(u as u64),
Ok(ZValue::Bool(b)) => Self::Bool(b),
Ok(ZValue::I16(i)) => Self::Int(i as i64),
Ok(ZValue::U16(u)) => Self::UInt(u as u64),
Ok(ZValue::I32(i)) => Self::Int(i as i64),
Ok(ZValue::U32(u)) => Self::UInt(u as u64),
Ok(ZValue::I64(i)) => Self::Int(i),
Ok(ZValue::U64(u)) => Self::UInt(u),
Ok(ZValue::F64(f)) => Self::Double(f),
Ok(ZValue::Str(s)) => Self::Str(s.to_string()),
Ok(ZValue::ObjectPath(path)) => Self::Str(path.to_string()),
Ok(ZValue::Array(a)) => Self::Array(a.iter().map(|v| v.into()).collect()),
Ok(ZValue::Dict(d)) => Self::Dict(
HashMap::<String, ZValue>::try_from(d)
.unwrap()
.into_iter()
.map(|(k, v)| (k, (&v).into()))
.collect(),
),
ZValue::Value(value) => Self::from(&**value),
Ok(ZValue::Value(value)) => Self::from(&*value),
_ => Self::__Unsupported,
}
}

View file

@ -33,8 +33,8 @@ impl Player {
/// Returns this player's `org.mpris.MediaPlayer2` instance
pub async fn media_player(&self) -> Result<MediaPlayer> {
let proxy = MediaPlayer2Proxy::builder(self.proxy.connection())
.destination(self.proxy.destination().to_owned())?
let proxy = MediaPlayer2Proxy::builder(self.proxy.inner().connection())
.destination(self.proxy.inner().destination().to_owned())?
.build()
.await?;
Ok(proxy.into())

View file

@ -8,7 +8,7 @@ use std::{
fmt::{self, Display},
str::FromStr,
};
use zvariant::{OwnedValue, Signature, Type, Value};
use zvariant::{Signature, Type, Value};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum PlaylistOrdering {
@ -38,7 +38,9 @@ impl<'a> TryFrom<Value<'a>> for PlaylistOrdering {
Value::Str(value) => Self::from_str(&value),
_ => Err(Error::IncorrectValue {
wanted: "Str",
actual: OwnedValue::from(value),
actual: value
.try_to_owned()
.map_err(|e| Error::Zbus(zbus::Error::Variant(e)))?,
}),
}
}

View file

@ -21,7 +21,7 @@ impl<'a> ActiveConnection<'a> {
let devices = self.0.devices().await?;
let mut out = Vec::with_capacity(devices.len());
for device in devices {
let device = DeviceProxy::builder(self.0.connection())
let device = DeviceProxy::builder(self.0.inner().connection())
.path(device)?
.build()
.await?;
@ -31,7 +31,7 @@ impl<'a> ActiveConnection<'a> {
}
pub async fn ip4_config(&self) -> Result<Ipv4Config<'a>> {
let config = Ipv4ConfigProxy::builder(self.0.connection())
let config = Ipv4ConfigProxy::builder(self.0.inner().connection())
.path(self.0.ip4_config().await?)?
.build()
.await?;
@ -39,7 +39,7 @@ impl<'a> ActiveConnection<'a> {
}
pub async fn ip6_config(&self) -> Result<Ipv6Config<'a>> {
let config = Ipv6ConfigProxy::builder(self.0.connection())
let config = Ipv6ConfigProxy::builder(self.0.inner().connection())
.path(self.0.ip6_config().await?)?
.build()
.await?;

View file

@ -30,7 +30,7 @@ impl<'a> Ipv4Config<'a> {
.filter_map(|mut map| {
let address = {
let address_str = map.remove("address")?;
let address_str = address_str.downcast_ref()?;
let address_str = address_str.downcast_ref().ok()?;
Ipv4Addr::from_str(address_str).ok()?
};
let prefix = u32::try_from(map.remove("prefix")?).ok()?;

View file

@ -29,7 +29,7 @@ impl<'a> Ipv6Config<'a> {
.filter_map(|mut map| {
let address = {
let address_str = map.remove("address")?;
let address_str = address_str.downcast_ref()?;
let address_str = address_str.downcast_ref().ok()?;
Ipv6Addr::from_str(address_str).ok()?
};
let prefix = u32::try_from(map.remove("prefix")?).ok()?;

View file

@ -28,7 +28,7 @@ pub struct Device<'a>(DeviceProxy<'a>);
impl<'a> Device<'a> {
pub async fn active_connection(&self) -> Result<ActiveConnection<'a>> {
let active_connection = self.0.active_connection().await?;
Ok(ActiveConnectionProxy::builder(self.0.connection())
Ok(ActiveConnectionProxy::builder(self.0.inner().connection())
.path(active_connection)?
.build()
.await?
@ -39,7 +39,7 @@ impl<'a> Device<'a> {
let available_connections = self.0.available_connections().await?;
let mut out = Vec::with_capacity(available_connections.len());
for connection in available_connections {
let connection = ActiveConnectionProxy::builder(self.0.connection())
let connection = ActiveConnectionProxy::builder(self.0.inner().connection())
.path(connection)?
.build()
.await?;
@ -62,36 +62,36 @@ impl<'a> Device<'a> {
pub async fn downcast_to_device(&'a self) -> Result<Option<SpecificDevice<'a>>> {
match self.device_type().await? {
DeviceType::Bluetooth => Ok(Some(SpecificDevice::Bluetooth(
BluetoothDeviceProxy::builder(self.0.connection())
.path(self.0.path())?
BluetoothDeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await?
.into(),
))),
DeviceType::Ethernet => Ok(Some(SpecificDevice::Wired(
WiredDeviceProxy::builder(self.0.connection())
.path(self.0.path())?
WiredDeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await?
.into(),
))),
DeviceType::Wifi => Ok(Some(SpecificDevice::Wireless(
WirelessDeviceProxy::builder(self.0.connection())
.path(self.0.path())?
WirelessDeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await?
.into(),
))),
DeviceType::TunTap => Ok(Some(SpecificDevice::TunTap(
TunDeviceProxy::builder(self.0.connection())
.path(self.0.path())?
TunDeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await?
.into(),
))),
DeviceType::WireGuard => Ok(Some(SpecificDevice::WireGuard(
WireGuardDeviceProxy::builder(self.0.connection())
.path(self.0.path())?
WireGuardDeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await?
.into(),
@ -105,7 +105,7 @@ impl<'a> Device<'a> {
}
pub async fn ip4_config(&self) -> Result<Ipv4Config<'a>> {
let config = Ipv4ConfigProxy::builder(self.0.connection())
let config = Ipv4ConfigProxy::builder(self.0.inner().connection())
.path(self.0.ip4_config().await?)?
.build()
.await?;
@ -113,7 +113,7 @@ impl<'a> Device<'a> {
}
pub async fn ip6_config(&self) -> Result<Ipv6Config<'a>> {
let config = Ipv6ConfigProxy::builder(self.0.connection())
let config = Ipv6ConfigProxy::builder(self.0.inner().connection())
.path(self.0.ip6_config().await?)?
.build()
.await?;

View file

@ -10,8 +10,8 @@ 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())?
DeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await
.map(Device::from)

View file

@ -10,8 +10,8 @@ pub struct TunDevice<'a>(TunDeviceProxy<'a>);
impl<'a> TunDevice<'a> {
pub async fn upcast(&'a self) -> Result<Device<'a>> {
DeviceProxy::builder(self.0.connection())
.path(self.0.path())?
DeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await
.map(Device::from)

View file

@ -10,8 +10,8 @@ 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())?
DeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await
.map(Device::from)

View file

@ -10,8 +10,8 @@ pub struct WireGuardDevice<'a>(WireGuardDeviceProxy<'a>);
impl<'a> WireGuardDevice<'a> {
pub async fn upcast(&'a self) -> Result<Device<'a>> {
DeviceProxy::builder(self.0.connection())
.path(self.0.path())?
DeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await
.map(Device::from)

View file

@ -20,7 +20,7 @@ impl<'a> WirelessDevice<'a> {
let access_points = self.0.get_access_points().await?;
let mut out = Vec::with_capacity(access_points.len());
for access_point in access_points {
let access_point = AccessPointProxy::builder(self.0.connection())
let access_point = AccessPointProxy::builder(self.0.inner().connection())
.path(access_point)?
.build()
.await?;
@ -33,7 +33,7 @@ impl<'a> WirelessDevice<'a> {
let access_points = self.0.get_all_access_points().await?;
let mut out = Vec::with_capacity(access_points.len());
for access_point in access_points {
let access_point = AccessPointProxy::builder(self.0.connection())
let access_point = AccessPointProxy::builder(self.0.inner().connection())
.path(access_point)?
.build()
.await?;
@ -46,7 +46,7 @@ impl<'a> WirelessDevice<'a> {
let access_points = self.0.access_points().await?;
let mut out = Vec::with_capacity(access_points.len());
for access_point in access_points {
let access_point = AccessPointProxy::builder(self.0.connection())
let access_point = AccessPointProxy::builder(self.0.inner().connection())
.path(access_point)?
.build()
.await?;
@ -56,7 +56,7 @@ impl<'a> WirelessDevice<'a> {
}
pub async fn active_access_point(&self) -> Result<AccessPoint<'a>> {
AccessPointProxy::builder(self.0.connection())
AccessPointProxy::builder(self.0.inner().connection())
.path(self.0.active_access_point().await?)?
.build()
.await
@ -64,8 +64,8 @@ impl<'a> WirelessDevice<'a> {
}
pub async fn upcast(&'a self) -> Result<Device<'a>> {
DeviceProxy::builder(self.0.connection())
.path(self.0.path())?
DeviceProxy::builder(self.0.inner().connection())
.path(self.0.inner().path())?
.build()
.await
.map(Device::from)

View file

@ -20,50 +20,50 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.AccessPoint",
default_service = "org.freedesktop.NetworkManager"
)]
trait AccessPoint {
/// Flags property
#[dbus_proxy(property)]
#[zbus(property)]
fn flags(&self) -> zbus::Result<u32>;
/// Frequency property
#[dbus_proxy(property)]
#[zbus(property)]
fn frequency(&self) -> zbus::Result<u32>;
/// HwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// LastSeen property
#[dbus_proxy(property)]
#[zbus(property)]
fn last_seen(&self) -> zbus::Result<i32>;
/// MaxBitrate property
#[dbus_proxy(property)]
#[zbus(property)]
fn max_bitrate(&self) -> zbus::Result<u32>;
/// Mode property
#[dbus_proxy(property)]
#[zbus(property)]
fn mode(&self) -> zbus::Result<u32>;
/// RsnFlags property
#[dbus_proxy(property)]
#[zbus(property)]
fn rsn_flags(&self) -> zbus::Result<u32>;
/// Ssid property
#[dbus_proxy(property)]
#[zbus(property)]
fn ssid(&self) -> zbus::Result<Vec<u8>>;
/// Strength property
#[dbus_proxy(property)]
#[zbus(property)]
fn strength(&self) -> zbus::Result<u8>;
/// WpaFlags property
#[dbus_proxy(property)]
#[zbus(property)]
fn wpa_flags(&self) -> zbus::Result<u32>;
}

View file

@ -20,74 +20,74 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Connection.Active",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait ActiveConnection {
/// Connection property
#[dbus_proxy(property)]
#[zbus(property)]
fn connection_(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Default property
#[dbus_proxy(property)]
#[zbus(property)]
fn default(&self) -> zbus::Result<bool>;
/// Default6 property
#[dbus_proxy(property)]
#[zbus(property)]
fn default6(&self) -> zbus::Result<bool>;
/// Devices property
#[dbus_proxy(property)]
#[zbus(property)]
fn devices(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// Dhcp4Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn dhcp4_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Dhcp6Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn dhcp6_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Id property
#[dbus_proxy(property)]
#[zbus(property)]
fn id(&self) -> zbus::Result<String>;
/// Ip4Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip4_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Ip6Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip6_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Master property
#[dbus_proxy(property)]
#[zbus(property)]
fn master(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// SpecificObject property
#[dbus_proxy(property)]
#[zbus(property)]
fn specific_object(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// State property
#[dbus_proxy(property)]
#[zbus(property)]
fn state(&self) -> zbus::Result<u32>;
/// StateFlags property
#[dbus_proxy(property)]
#[zbus(property)]
fn state_flags(&self) -> zbus::Result<u32>;
/// Type property
#[dbus_proxy(property)]
#[zbus(property)]
fn type_(&self) -> zbus::Result<String>;
/// Uuid property
#[dbus_proxy(property)]
#[zbus(property)]
fn uuid(&self) -> zbus::Result<String>;
/// Vpn property
#[dbus_proxy(property)]
#[zbus(property)]
fn vpn(&self) -> zbus::Result<bool>;
}

View file

@ -20,68 +20,68 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.IP4Config",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait Ipv4Config {
/// AddressData property
#[dbus_proxy(property)]
#[zbus(property)]
fn address_data(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// Addresses property
#[dbus_proxy(property)]
#[zbus(property)]
fn addresses(&self) -> zbus::Result<Vec<Vec<u32>>>;
/// DnsOptions property
#[dbus_proxy(property)]
#[zbus(property)]
fn dns_options(&self) -> zbus::Result<Vec<String>>;
/// DnsPriority property
#[dbus_proxy(property)]
#[zbus(property)]
fn dns_priority(&self) -> zbus::Result<i32>;
/// Domains property
#[dbus_proxy(property)]
#[zbus(property)]
fn domains(&self) -> zbus::Result<Vec<String>>;
/// Gateway property
#[dbus_proxy(property)]
#[zbus(property)]
fn gateway(&self) -> zbus::Result<String>;
/// NameserverData property
#[dbus_proxy(property)]
#[zbus(property)]
fn nameserver_data(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// Nameservers property
#[dbus_proxy(property)]
#[zbus(property)]
fn nameservers(&self) -> zbus::Result<Vec<u32>>;
/// RouteData property
#[dbus_proxy(property)]
#[zbus(property)]
fn route_data(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// Routes property
#[dbus_proxy(property)]
#[zbus(property)]
fn routes(&self) -> zbus::Result<Vec<Vec<u32>>>;
/// Searches property
#[dbus_proxy(property)]
#[zbus(property)]
fn searches(&self) -> zbus::Result<Vec<String>>;
/// WinsServerData property
#[dbus_proxy(property)]
#[zbus(property)]
fn wins_server_data(&self) -> zbus::Result<Vec<String>>;
/// WinsServers property
#[dbus_proxy(property)]
#[zbus(property)]
fn wins_servers(&self) -> zbus::Result<Vec<u32>>;
}

View file

@ -20,54 +20,54 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.IP6Config",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait Ipv6Config {
/// AddressData property
#[dbus_proxy(property)]
#[zbus(property)]
fn address_data(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// Addresses property
#[dbus_proxy(property)]
#[zbus(property)]
fn addresses(&self) -> zbus::Result<Vec<(Vec<u8>, u32, Vec<u8>)>>;
/// DnsOptions property
#[dbus_proxy(property)]
#[zbus(property)]
fn dns_options(&self) -> zbus::Result<Vec<String>>;
/// DnsPriority property
#[dbus_proxy(property)]
#[zbus(property)]
fn dns_priority(&self) -> zbus::Result<i32>;
/// Domains property
#[dbus_proxy(property)]
#[zbus(property)]
fn domains(&self) -> zbus::Result<Vec<String>>;
/// Gateway property
#[dbus_proxy(property)]
#[zbus(property)]
fn gateway(&self) -> zbus::Result<String>;
/// Nameservers property
#[dbus_proxy(property)]
#[zbus(property)]
fn nameservers(&self) -> zbus::Result<Vec<Vec<u8>>>;
/// RouteData property
#[dbus_proxy(property)]
#[zbus(property)]
fn route_data(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// Routes property
#[dbus_proxy(property)]
#[zbus(property)]
fn routes(&self) -> zbus::Result<Vec<(Vec<u8>, u32, Vec<u8>, u32)>>;
/// Searches property
#[dbus_proxy(property)]
#[zbus(property)]
fn searches(&self) -> zbus::Result<Vec<String>>;
}

View file

@ -26,23 +26,23 @@ pub mod wired;
pub mod wireguard;
pub mod wireless;
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device.Generic",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait GenericDevice {
/// HwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// TypeDescription property
#[dbus_proxy(property)]
#[zbus(property)]
fn type_description(&self) -> zbus::Result<String>;
}
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device",
default_service = "org.freedesktop.NetworkManager"
)]
@ -77,132 +77,132 @@ pub trait Device {
) -> zbus::Result<()>;
/// ActiveConnection property
#[dbus_proxy(property)]
#[zbus(property)]
fn active_connection(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Autoconnect property
#[dbus_proxy(property)]
#[zbus(property)]
fn autoconnect(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_autoconnect(&self, value: bool) -> zbus::Result<()>;
/// AvailableConnections property
#[dbus_proxy(property)]
#[zbus(property)]
fn available_connections(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// Capabilities property
#[dbus_proxy(property)]
#[zbus(property)]
fn capabilities(&self) -> zbus::Result<u32>;
/// DeviceType property
#[dbus_proxy(property)]
#[zbus(property)]
fn device_type(&self) -> zbus::Result<u32>;
/// Dhcp4Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn dhcp4_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Dhcp6Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn dhcp6_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Driver property
#[dbus_proxy(property)]
#[zbus(property)]
fn driver(&self) -> zbus::Result<String>;
/// DriverVersion property
#[dbus_proxy(property)]
#[zbus(property)]
fn driver_version(&self) -> zbus::Result<String>;
/// FirmwareMissing property
#[dbus_proxy(property)]
#[zbus(property)]
fn firmware_missing(&self) -> zbus::Result<bool>;
/// FirmwareVersion property
#[dbus_proxy(property)]
#[zbus(property)]
fn firmware_version(&self) -> zbus::Result<String>;
/// HwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// Interface property
#[dbus_proxy(property)]
#[zbus(property)]
fn interface(&self) -> zbus::Result<String>;
/// InterfaceFlags property
#[dbus_proxy(property)]
#[zbus(property)]
fn interface_flags(&self) -> zbus::Result<u32>;
/// Ip4Address property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip4_address(&self) -> zbus::Result<u32>;
/// Ip4Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip4_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Ip4Connectivity property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip4_connectivity(&self) -> zbus::Result<u32>;
/// Ip6Config property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip6_config(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Ip6Connectivity property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip6_connectivity(&self) -> zbus::Result<u32>;
/// IpInterface property
#[dbus_proxy(property)]
#[zbus(property)]
fn ip_interface(&self) -> zbus::Result<String>;
/// LldpNeighbors property
#[dbus_proxy(property)]
#[zbus(property)]
fn lldp_neighbors(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// Managed property
#[dbus_proxy(property)]
#[zbus(property)]
fn managed(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_managed(&self, value: bool) -> zbus::Result<()>;
/// Metered property
#[dbus_proxy(property)]
#[zbus(property)]
fn metered(&self) -> zbus::Result<u32>;
/// Mtu property
#[dbus_proxy(property)]
#[zbus(property)]
fn mtu(&self) -> zbus::Result<u32>;
/// NmPluginMissing property
#[dbus_proxy(property)]
#[zbus(property)]
fn nm_plugin_missing(&self) -> zbus::Result<bool>;
/// Path property
#[dbus_proxy(property)]
#[zbus(property)]
fn path_(&self) -> zbus::Result<String>;
/// PhysicalPortId property
#[dbus_proxy(property)]
#[zbus(property)]
fn physical_port_id(&self) -> zbus::Result<String>;
/// Real property
#[dbus_proxy(property)]
#[zbus(property)]
fn real(&self) -> zbus::Result<bool>;
/// State property
#[dbus_proxy(property)]
#[zbus(property)]
fn state(&self) -> zbus::Result<u32>;
/// StateReason property
#[dbus_proxy(property)]
#[zbus(property)]
fn state_reason(&self) -> zbus::Result<(u32, u32)>;
/// Udi property
#[dbus_proxy(property)]
#[zbus(property)]
fn udi(&self) -> zbus::Result<String>;
}

View file

@ -11,22 +11,22 @@
//! section of the zbus documentation.
//!
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device.Bluetooth",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait BluetoothDevice {
/// BtCapabilities property
#[dbus_proxy(property)]
#[zbus(property)]
fn bt_capabilities(&self) -> zbus::Result<u32>;
/// HwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// Name property
#[dbus_proxy(property)]
#[zbus(property)]
fn name(&self) -> zbus::Result<String>;
}

View file

@ -11,38 +11,38 @@
//! section of the zbus documentation.
//!
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device.Tun",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait TunDevice {
/// Group property
#[dbus_proxy(property)]
#[zbus(property)]
fn group(&self) -> zbus::Result<i64>;
/// HwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// Mode property
#[dbus_proxy(property)]
#[zbus(property)]
fn mode(&self) -> zbus::Result<String>;
/// MultiQueue property
#[dbus_proxy(property)]
#[zbus(property)]
fn multi_queue(&self) -> zbus::Result<bool>;
/// NoPi property
#[dbus_proxy(property)]
#[zbus(property)]
fn no_pi(&self) -> zbus::Result<bool>;
/// Owner property
#[dbus_proxy(property)]
#[zbus(property)]
fn owner(&self) -> zbus::Result<i64>;
/// VnetHdr property
#[dbus_proxy(property)]
#[zbus(property)]
fn vnet_hdr(&self) -> zbus::Result<bool>;
}

View file

@ -20,30 +20,30 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device.Wired",
default_service = "org.freedesktop.NetworkManager"
)]
trait WiredDevice {
/// Carrier property
#[dbus_proxy(property)]
#[zbus(property)]
fn carrier(&self) -> zbus::Result<bool>;
/// HwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// PermHwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn perm_hw_address(&self) -> zbus::Result<String>;
/// S390Subchannels property
#[dbus_proxy(property)]
#[zbus(property)]
fn s390subchannels(&self) -> zbus::Result<Vec<String>>;
/// Speed property
#[dbus_proxy(property)]
#[zbus(property)]
fn speed(&self) -> zbus::Result<u32>;
}

View file

@ -11,22 +11,22 @@
//! section of the zbus documentation.
//!
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device.WireGuard",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait WireGuardDevice {
/// FwMark property
#[dbus_proxy(property)]
#[zbus(property)]
fn fw_mark(&self) -> zbus::Result<u32>;
/// ListenPort property
#[dbus_proxy(property)]
#[zbus(property)]
fn listen_port(&self) -> zbus::Result<u16>;
/// PublicKey property
#[dbus_proxy(property)]
#[zbus(property)]
fn public_key(&self) -> zbus::Result<Vec<u8>>;
}

View file

@ -20,9 +20,9 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device.Wireless",
default_service = "org.freedesktop.NetworkManager"
)]
@ -40,45 +40,45 @@ pub trait WirelessDevice {
) -> zbus::Result<()>;
/// AccessPointAdded signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn access_point_added(&self, access_point: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// AccessPointRemoved signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn access_point_removed(
&self,
access_point: zbus::zvariant::ObjectPath<'_>,
) -> zbus::Result<()>;
/// AccessPoints property
#[dbus_proxy(property)]
#[zbus(property)]
fn access_points(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// ActiveAccessPoint property
#[dbus_proxy(property)]
#[zbus(property)]
fn active_access_point(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Bitrate property
#[dbus_proxy(property)]
#[zbus(property)]
fn bitrate(&self) -> zbus::Result<u32>;
/// HwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// LastScan property
#[dbus_proxy(property)]
#[zbus(property)]
fn last_scan(&self) -> zbus::Result<i64>;
/// Mode property
#[dbus_proxy(property)]
#[zbus(property)]
fn mode(&self) -> zbus::Result<u32>;
/// PermHwAddress property
#[dbus_proxy(property)]
#[zbus(property)]
fn perm_hw_address(&self) -> zbus::Result<String>;
/// WirelessCapabilities property
#[dbus_proxy(property)]
#[zbus(property)]
fn wireless_capabilities(&self) -> zbus::Result<u32>;
}

View file

@ -29,9 +29,9 @@ pub mod enums;
pub mod settings;
pub mod statistics;
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager",
default_service = "org.freedesktop.NetworkManager",
default_path = "/org/freedesktop/NetworkManager"
@ -136,125 +136,125 @@ pub trait NetworkManager {
fn sleep(&self, sleep: bool) -> zbus::Result<()>;
/// CheckPermissions signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn check_permissions(&self) -> zbus::Result<()>;
/// DeviceAdded signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn device_added(&self, device_path: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// DeviceRemoved signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn device_removed(&self, device_path: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// ActivatingConnection property
#[dbus_proxy(property)]
#[zbus(property)]
fn activating_connection(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// ActiveConnections property
#[dbus_proxy(property)]
#[zbus(property)]
fn active_connections(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// AllDevices property
#[dbus_proxy(property)]
#[zbus(property)]
fn all_devices(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// Capabilities property
#[dbus_proxy(property)]
#[zbus(property)]
fn capabilities(&self) -> zbus::Result<Vec<u32>>;
/// Checkpoints property
#[dbus_proxy(property)]
#[zbus(property)]
fn checkpoints(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// Connectivity property
#[dbus_proxy(property)]
#[zbus(property)]
fn connectivity(&self) -> zbus::Result<u32>;
/// ConnectivityCheckAvailable property
#[dbus_proxy(property)]
#[zbus(property)]
fn connectivity_check_available(&self) -> zbus::Result<bool>;
/// ConnectivityCheckEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn connectivity_check_enabled(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_connectivity_check_enabled(&self, value: bool) -> zbus::Result<()>;
/// ConnectivityCheckUri property
#[dbus_proxy(property)]
#[zbus(property)]
fn connectivity_check_uri(&self) -> zbus::Result<String>;
/// Devices property
#[dbus_proxy(property)]
#[zbus(property)]
fn devices(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// GlobalDnsConfiguration property
#[dbus_proxy(property)]
#[zbus(property)]
fn global_dns_configuration(
&self,
) -> zbus::Result<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_global_dns_configuration(
&self,
value: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>,
) -> zbus::Result<()>;
/// Metered property
#[dbus_proxy(property)]
#[zbus(property)]
fn metered(&self) -> zbus::Result<u32>;
/// NetworkingEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn networking_enabled(&self) -> zbus::Result<bool>;
/// PrimaryConnection property
#[dbus_proxy(property)]
#[zbus(property)]
fn primary_connection(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// PrimaryConnectionType property
#[dbus_proxy(property)]
#[zbus(property)]
fn primary_connection_type(&self) -> zbus::Result<String>;
/// Startup property
#[dbus_proxy(property)]
#[zbus(property)]
fn startup(&self) -> zbus::Result<bool>;
/// State property
#[dbus_proxy(property)]
#[zbus(property)]
fn state(&self) -> zbus::Result<u32>;
/// Version property
#[dbus_proxy(property)]
#[zbus(property)]
fn version(&self) -> zbus::Result<String>;
/// WimaxEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn wimax_enabled(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_wimax_enabled(&self, value: bool) -> zbus::Result<()>;
/// WimaxHardwareEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn wimax_hardware_enabled(&self) -> zbus::Result<bool>;
/// WirelessEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn wireless_enabled(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_wireless_enabled(&self, value: bool) -> zbus::Result<()>;
/// WirelessHardwareEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn wireless_hardware_enabled(&self) -> zbus::Result<bool>;
/// WwanEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn wwan_enabled(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_wwan_enabled(&self, value: bool) -> zbus::Result<()>;
/// WwanHardwareEnabled property
#[dbus_proxy(property)]
#[zbus(property)]
fn wwan_hardware_enabled(&self) -> zbus::Result<bool>;
}

View file

@ -22,9 +22,9 @@
pub mod connection;
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Settings",
default_service = "org.freedesktop.NetworkManager",
default_path = "/org/freedesktop/NetworkManager/Settings"
@ -78,22 +78,22 @@ pub trait Settings {
fn save_hostname(&self, hostname: &str) -> zbus::Result<()>;
/// ConnectionRemoved signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn connection_removed(&self, connection: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// NewConnection signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn new_connection(&self, connection: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// CanModify property
#[dbus_proxy(property)]
#[zbus(property)]
fn can_modify(&self) -> zbus::Result<bool>;
/// Connections property
#[dbus_proxy(property)]
#[zbus(property)]
fn connections(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// Hostname property
#[dbus_proxy(property)]
#[zbus(property)]
fn hostname(&self) -> zbus::Result<String>;
}

View file

@ -20,9 +20,9 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Settings.Connection",
default_service = "org.freedesktop.NetworkManager"
)]
@ -87,22 +87,22 @@ pub trait ConnectionSettings {
) -> zbus::Result<()>;
/// Removed signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn removed(&self) -> zbus::Result<()>;
/// Updated signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn updated(&self) -> zbus::Result<()>;
/// Filename property
#[dbus_proxy(property)]
#[zbus(property)]
fn filename(&self) -> zbus::Result<String>;
/// Flags property
#[dbus_proxy(property)]
#[zbus(property)]
fn flags(&self) -> zbus::Result<u32>;
/// Unsaved property
#[dbus_proxy(property)]
#[zbus(property)]
fn unsaved(&self) -> zbus::Result<bool>;
}

View file

@ -20,24 +20,24 @@
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.NetworkManager.Device.Statistics",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait Statistics {
/// RefreshRateMs property
#[dbus_proxy(property)]
#[zbus(property)]
fn refresh_rate_ms(&self) -> zbus::Result<u32>;
#[dbus_proxy(property)]
#[zbus(property)]
fn set_refresh_rate_ms(&self, value: u32) -> zbus::Result<()>;
/// RxBytes property
#[dbus_proxy(property)]
#[zbus(property)]
fn rx_bytes(&self) -> zbus::Result<u64>;
/// TxBytes property
#[dbus_proxy(property)]
#[zbus(property)]
fn tx_bytes(&self) -> zbus::Result<u64>;
}

View file

@ -35,14 +35,14 @@ impl<'a> NetworkManager<'a> {
connection: &'a Connection<'a>,
device: &'a Device<'a>,
) -> Result<ActiveConnection<'a>> {
let connection = connection.path();
let device = device.path();
let connection = connection.inner().path();
let device = device.inner().path();
let specific_object = ObjectPath::from_static_str("/").unwrap();
let active_connection_path = self
.0
.activate_connection(connection, device, &specific_object)
.await?;
ActiveConnectionProxy::builder(self.0.connection())
ActiveConnectionProxy::builder(self.0.inner().connection())
.path(active_connection_path)?
.build()
.await
@ -53,7 +53,7 @@ impl<'a> NetworkManager<'a> {
let active_connections = self.0.active_connections().await?;
let mut out = Vec::with_capacity(active_connections.len());
for active_connection in active_connections {
let active_connection = ActiveConnectionProxy::builder(self.0.connection())
let active_connection = ActiveConnectionProxy::builder(self.0.inner().connection())
.path(active_connection)?
.build()
.await?;
@ -74,14 +74,16 @@ impl<'a> NetworkManager<'a> {
}
pub async fn deactivate_connection(&self, connection: &'a ActiveConnection<'a>) -> Result<()> {
self.0.deactivate_connection(connection.path()).await
self.0
.deactivate_connection(connection.inner().path())
.await
}
pub async fn devices(&self) -> Result<Vec<Device<'a>>> {
let devices = self.0.get_all_devices().await?;
let mut out = Vec::with_capacity(devices.len());
for device in devices {
let device = DeviceProxy::builder(self.0.connection())
let device = DeviceProxy::builder(self.0.inner().connection())
.path(device)?
.build()
.await?;
@ -94,7 +96,7 @@ impl<'a> NetworkManager<'a> {
let devices = self.0.get_all_devices().await?;
let mut out = Vec::with_capacity(devices.len());
for device in devices {
let device = DeviceProxy::builder(self.0.connection())
let device = DeviceProxy::builder(self.0.inner().connection())
.path(device)?
.build()
.await?;
@ -108,6 +110,6 @@ impl<'a> NetworkManager<'a> {
}
pub async fn settings(&'a self) -> Result<NetworkManagerSettings<'a>> {
NetworkManagerSettings::new(self.0.connection()).await
NetworkManagerSettings::new(self.0.inner().connection()).await
}
}

View file

@ -27,7 +27,7 @@ impl<'a> NetworkManagerSettings<'a> {
let connections = self.0.list_connections().await?;
let mut out = Vec::with_capacity(connections.len());
for connection in connections {
let connection = ConnectionSettingsProxy::builder(self.0.connection())
let connection = ConnectionSettingsProxy::builder(self.0.inner().connection())
.path(connection)?
.build()
.await?;

View file

@ -42,7 +42,7 @@ macro_rules! derive_value_build {
ret
}
pub fn build<'a>(&'a self) -> std::collections::HashMap<String, zbus::zvariant::Value<'a>> {
pub fn build(&self) -> std::collections::HashMap<String, zbus::zvariant::Value<'_>> {
let mut out = std::collections::HashMap::new();
$(
if let Some(val) = &self.$arg {

View file

@ -22,34 +22,34 @@
use std::collections::HashMap;
use zbus::{
dbus_proxy,
proxy,
zvariant::{self, OwnedValue},
};
#[dbus_proxy(
#[proxy(
interface = "net.hadess.SwitcherooControl",
default_service = "net.hadess.SwitcherooControl",
default_path = "/net/hadess/SwitcherooControl"
)]
trait SwitcherooControl {
/// GPUs property
#[dbus_proxy(property, name = "GPUs")]
#[zbus(property, name = "GPUs")]
fn gpus(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// HasDualGpu property
#[dbus_proxy(property)]
#[zbus(property)]
fn has_dual_gpu(&self) -> zbus::Result<bool>;
/// NumGPUs property
#[dbus_proxy(property, name = "NumGPUs")]
#[zbus(property, name = "NumGPUs")]
fn num_gpus(&self) -> zbus::Result<u32>;
}
impl<'a> SwitcherooControlProxy<'a> {
pub fn get_cached_gpus(&self) -> zbus::Result<Vec<Gpu>> {
let res = self.cached_gpus().map_err(|err| zbus::Error::from(err))?;
let res = self.cached_gpus()?;
if let Some(res) = res {
convert_gpus(res)
} else {
@ -66,7 +66,7 @@ impl<'a> SwitcherooControlProxy<'a> {
impl<'a> SwitcherooControlProxyBlocking<'a> {
pub fn get_cached_gpus(&self) -> zbus::Result<Vec<Gpu>> {
let res = self.cached_gpus().map_err(|err| zbus::Error::from(err))?;
let res = self.cached_gpus()?;
if let Some(res) = res {
convert_gpus(res)
} else {
@ -88,12 +88,12 @@ impl TryFrom<HashMap<String, OwnedValue>> for Gpu {
let name = value
.get("Name")
.ok_or(zvariant::Error::IncorrectType)?
.to_owned()
.try_clone()?
.try_into()?;
let environment: Vec<String> = value
.get("Environment")
.ok_or(zvariant::Error::IncorrectType)?
.to_owned()
.try_clone()?
.try_into()?;
let environment: HashMap<String, String> = environment
.chunks_exact(2)

View file

@ -17,11 +17,8 @@ zbus.workspace = true
[dev-dependencies]
chrono = "0.4.23"
chrono-tz = "0.8.1"
[dev-dependencies.zbus]
version = "3.14"
default-features = false
features = ["tokio"]
zbus.workspace = true
zbus.features = ["tokio"]
[dev-dependencies.tokio]
version = "1.25.0"

View file

@ -15,9 +15,9 @@
//! * [`zbus::fdo::PropertiesProxy`]
//!
use zbus::dbus_proxy;
use zbus::proxy;
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.timedate1",
default_service = "org.freedesktop.timedate1",
default_path = "/org/freedesktop/timedate1"
@ -27,7 +27,7 @@ trait TimeDate {
fn list_timezones(&self) -> zbus::Result<Vec<String>>;
/// Control whether the RTC is in local time zone or UTC.
#[dbus_proxy(name = "SetLocalRTC")]
#[zbus(name = "SetLocalRTC")]
fn set_local_rtc(
&self,
local_rtc: bool,
@ -36,7 +36,7 @@ trait TimeDate {
) -> zbus::Result<()>;
/// Control whether the system clock is synchronized with the network using `systemd-timesyncd`.
#[dbus_proxy(name = "SetNTP")]
#[zbus(name = "SetNTP")]
fn set_ntp(&self, use_ntp: bool, interactive: bool) -> zbus::Result<()>;
/// Change the system clock.
@ -46,30 +46,30 @@ trait TimeDate {
fn set_timezone(&self, timezone: &str, interactive: bool) -> zbus::Result<()>;
/// Shows whether a service to perform time synchronization over network is available.
#[dbus_proxy(property, name = "CanNTP")]
#[zbus(property, name = "CanNTP")]
fn can_ntp(&self) -> zbus::Result<bool>;
/// Shows whether the RTC is configured to use UTC or the local time zone.
#[dbus_proxy(property, name = "LocalRTC")]
#[zbus(property, name = "LocalRTC")]
fn local_rtc(&self) -> zbus::Result<bool>;
/// Shows whether the NTP service is enabled.
#[dbus_proxy(property, name = "NTP")]
#[zbus(property, name = "NTP")]
fn ntp(&self) -> zbus::Result<bool>;
/// Shows whether the kernel reports the time as synchronized.
#[dbus_proxy(property, name = "NTPSynchronized")]
#[zbus(property, name = "NTPSynchronized")]
fn ntp_synchronized(&self) -> zbus::Result<bool>;
/// Shows the current time in RTC.
#[dbus_proxy(property, name = "RTCTimeUSec")]
#[zbus(property, name = "RTCTimeUSec")]
fn rtctime_usec(&self) -> zbus::Result<u64>;
/// Shows the current time.
#[dbus_proxy(property, name = "TimeUSec")]
#[zbus(property, name = "TimeUSec")]
fn time_usec(&self) -> zbus::Result<u64>;
/// Shows the currently-configured time zone.
#[dbus_proxy(property)]
#[zbus(property)]
fn timezone(&self) -> zbus::Result<String>;
}

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: MPL-2.0
use serde_repr::{Deserialize_repr, Serialize_repr};
use zbus::dbus_proxy;
use zbus::proxy;
use zbus::zvariant::OwnedValue;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Deserialize_repr, Serialize_repr, OwnedValue)]
@ -43,80 +43,80 @@ pub enum BatteryLevel {
Full = 8,
}
#[dbus_proxy(
#[proxy(
interface = "org.freedesktop.UPower.Device",
default_service = "org.freedesktop.UPower",
assume_defaults = false
)]
trait Device {
#[dbus_proxy(property)]
#[zbus(property)]
fn battery_level(&self) -> zbus::Result<BatteryLevel>;
#[dbus_proxy(property)]
#[zbus(property)]
fn capacity(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn energy(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn energy_empty(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn energy_full(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn energy_full_design(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn has_history(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn has_statistics(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn icon_name(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
#[zbus(property)]
fn is_present(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn is_rechargeable(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn luminosity(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn model(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
#[zbus(property)]
fn native_path(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
#[zbus(property)]
fn online(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
#[zbus(property)]
fn percentage(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
#[zbus(property)]
fn power_supply(&self) -> zbus::Result<bool>;
fn refresh(&self) -> zbus::Result<()>;
#[dbus_proxy(property)]
#[zbus(property)]
fn serial(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
#[zbus(property)]
fn state(&self) -> zbus::Result<BatteryState>;
#[dbus_proxy(property)]
#[zbus(property)]
fn temperature(&self) -> zbus::Result<f64>;
#[dbus_proxy(property, name = "Type")]
#[zbus(property, name = "Type")]
fn type_(&self) -> zbus::Result<BatteryType>;
#[dbus_proxy(property)]
#[zbus(property)]
fn vendor(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
#[zbus(property)]
fn voltage(&self) -> zbus::Result<f64>;
}

View file

@ -1,11 +1,11 @@
// Copyright 2021 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use zbus::dbus_proxy;
use zbus::proxy;
use crate::device::{DeviceProxy, DeviceProxyBlocking};
#[dbus_proxy(interface = "org.freedesktop.UPower", assume_defaults = true)]
#[proxy(interface = "org.freedesktop.UPower", assume_defaults = true)]
trait UPower {
/// EnumerateDevices method
fn enumerate_devices(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
@ -14,30 +14,30 @@ trait UPower {
fn get_critical_action(&self) -> zbus::Result<String>;
/// GetDisplayDevice method
#[dbus_proxy(object = "Device")]
#[zbus(object = "Device")]
fn get_display_device(&self);
/// DeviceAdded signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn device_added(&self, device: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// DeviceRemoved signal
#[dbus_proxy(signal)]
#[zbus(signal)]
fn device_removed(&self, device: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// DaemonVersion property
#[dbus_proxy(property)]
#[zbus(property)]
fn daemon_version(&self) -> zbus::Result<String>;
/// LidIsClosed property
#[dbus_proxy(property)]
#[zbus(property)]
fn lid_is_closed(&self) -> zbus::Result<bool>;
/// LidIsPresent property
#[dbus_proxy(property)]
#[zbus(property)]
fn lid_is_present(&self) -> zbus::Result<bool>;
/// OnBattery property
#[dbus_proxy(property)]
#[zbus(property)]
fn on_battery(&self) -> zbus::Result<bool>;
}