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"] } serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0" thiserror = "1.0"
time = { version = "0.3", features = ["parsing"] } time = { version = "0.3", features = ["parsing"] }
zbus = { version = "3.15.0" } zbus = { version = "4.2.1" }
zvariant = { version = "3.15.0"} zvariant = { version = "4.1.0"}

View file

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

View file

@ -1,6 +1,6 @@
use serde_repr::{Deserialize_repr, Serialize_repr}; use serde_repr::{Deserialize_repr, Serialize_repr};
use zbus::{ use zbus::{
dbus_proxy, proxy,
zvariant::{ObjectPath, OwnedValue, Type}, zvariant::{ObjectPath, OwnedValue, Type},
Result, Result,
}; };
@ -43,32 +43,32 @@ impl TryFrom<OwnedValue> for Accuracy {
} }
} }
#[dbus_proxy( #[proxy(
default_service = "org.freedesktop.GeoClue2", default_service = "org.freedesktop.GeoClue2",
interface = "org.freedesktop.GeoClue2.Manager", interface = "org.freedesktop.GeoClue2.Manager",
default_path = "/org/freedesktop/GeoClue2/Manager" default_path = "/org/freedesktop/GeoClue2/Manager"
)] )]
trait 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. /// 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); fn get_client(&self);
/// Use this method to explicitly destroy a client, created using GetClient() or CreateClient(). /// 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). /// 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>); fn delete_client<'a>(&self, client: ObjectPath<'a>);
/// InUse property /// InUse property
#[dbus_proxy(property)] #[zbus(property)]
fn in_use(&self) -> Result<bool>; fn in_use(&self) -> Result<bool>;
/// AvailableAccuracyLevel property /// AvailableAccuracyLevel property
#[dbus_proxy(property)] #[zbus(property)]
fn available_accuracy_level(&self) -> zbus::Result<Accuracy>; fn available_accuracy_level(&self) -> zbus::Result<Accuracy>;
} }
#[dbus_proxy( #[proxy(
default_service = "org.freedesktop.GeoClue2", default_service = "org.freedesktop.GeoClue2",
interface = "org.freedesktop.GeoClue2.Client" interface = "org.freedesktop.GeoClue2.Client"
)] )]
@ -80,7 +80,7 @@ trait Client {
fn stop(&self) -> zbus::Result<()>; fn stop(&self) -> zbus::Result<()>;
/// LocationUpdated signal /// LocationUpdated signal
#[dbus_proxy(signal)] #[zbus(signal)]
fn location_updated( fn location_updated(
&self, &self,
old: zbus::zvariant::ObjectPath<'_>, old: zbus::zvariant::ObjectPath<'_>,
@ -88,60 +88,60 @@ trait Client {
) -> zbus::Result<()>; ) -> zbus::Result<()>;
/// Active property /// Active property
#[dbus_proxy(property)] #[zbus(property)]
fn active(&self) -> zbus::Result<bool>; fn active(&self) -> zbus::Result<bool>;
/// DesktopId property /// DesktopId property
#[dbus_proxy(property)] #[zbus(property)]
fn desktop_id(&self) -> zbus::Result<String>; fn desktop_id(&self) -> zbus::Result<String>;
#[dbus_proxy(property)] #[zbus(property)]
fn set_desktop_id(&self, value: &str) -> zbus::Result<()>; fn set_desktop_id(&self, value: &str) -> zbus::Result<()>;
/// DistanceThreshold property /// DistanceThreshold property
#[dbus_proxy(property)] #[zbus(property)]
fn distance_threshold(&self) -> zbus::Result<u32>; fn distance_threshold(&self) -> zbus::Result<u32>;
#[dbus_proxy(property)] #[zbus(property)]
fn set_distance_threshold(&self, value: u32) -> zbus::Result<()>; fn set_distance_threshold(&self, value: u32) -> zbus::Result<()>;
/// Location property /// Location property
#[dbus_proxy(property, object = "Location")] #[zbus(property, object = "Location")]
fn location(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>; fn location(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// RequestedAccuracyLevel property /// RequestedAccuracyLevel property
#[dbus_proxy(property)] #[zbus(property)]
fn requested_accuracy_level(&self) -> zbus::Result<Accuracy>; fn requested_accuracy_level(&self) -> zbus::Result<Accuracy>;
#[dbus_proxy(property)] #[zbus(property)]
fn set_requested_accuracy_level(&self, value: u32) -> zbus::Result<()>; fn set_requested_accuracy_level(&self, value: u32) -> zbus::Result<()>;
/// TimeThreshold property /// TimeThreshold property
#[dbus_proxy(property)] #[zbus(property)]
fn time_threshold(&self) -> zbus::Result<u32>; fn time_threshold(&self) -> zbus::Result<u32>;
fn set_time_threshold(&self, value: u32) -> zbus::Result<()>; fn set_time_threshold(&self, value: u32) -> zbus::Result<()>;
} }
#[dbus_proxy( #[proxy(
default_service = "org.freedesktop.GeoClue2", default_service = "org.freedesktop.GeoClue2",
interface = "org.freedesktop.GeoClue2.Location" interface = "org.freedesktop.GeoClue2.Location"
)] )]
trait Location { trait Location {
/// The latitude of the location, in degrees. /// The latitude of the location, in degrees.
#[dbus_proxy(property)] #[zbus(property)]
fn latitude(&self) -> Result<f64>; fn latitude(&self) -> Result<f64>;
/// The longitude of the location, in degrees. /// The longitude of the location, in degrees.
#[dbus_proxy(property)] #[zbus(property)]
fn longitude(&self) -> Result<f64>; fn longitude(&self) -> Result<f64>;
/// The accuracy of the location fix, in meters. /// The accuracy of the location fix, in meters.
#[dbus_proxy(property)] #[zbus(property)]
fn accuracy(&self) -> Result<f64>; fn accuracy(&self) -> Result<f64>;
/// The altitude of the location fix, in meters. /// The altitude of the location fix, in meters.
/// When unknown, its set to minimum f64 value, -1.7976931348623157e+308. /// When unknown, its set to minimum f64 value, -1.7976931348623157e+308.
#[dbus_proxy(property)] #[zbus(property)]
fn altitude(&self) -> Result<f64>; fn altitude(&self) -> Result<f64>;
/// Speed in meters per second. /// Speed in meters per second.
/// When unknown, it's set to -1.0. /// When unknown, it's set to -1.0.
#[dbus_proxy(property)] #[zbus(property)]
fn speed(&self) -> Result<f64>; 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. /// 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>; fn heading(&self) -> Result<f64>;
} }

View file

@ -20,9 +20,9 @@
//! //!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …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", interface = "org.mpris.MediaPlayer2",
default_path = "/org/mpris/MediaPlayer2" default_path = "/org/mpris/MediaPlayer2"
)] )]
@ -34,30 +34,30 @@ trait MediaPlayer2 {
fn raise(&self) -> zbus::Result<()>; fn raise(&self) -> zbus::Result<()>;
/// CanQuit property /// CanQuit property
#[dbus_proxy(property)] #[zbus(property)]
fn can_quit(&self) -> zbus::Result<bool>; fn can_quit(&self) -> zbus::Result<bool>;
/// CanRaise property /// CanRaise property
#[dbus_proxy(property)] #[zbus(property)]
fn can_raise(&self) -> zbus::Result<bool>; fn can_raise(&self) -> zbus::Result<bool>;
/// DesktopEntry property /// DesktopEntry property
#[dbus_proxy(property)] #[zbus(property)]
fn desktop_entry(&self) -> zbus::Result<String>; fn desktop_entry(&self) -> zbus::Result<String>;
/// HasTrackList property /// HasTrackList property
#[dbus_proxy(property)] #[zbus(property)]
fn has_track_list(&self) -> zbus::Result<bool>; fn has_track_list(&self) -> zbus::Result<bool>;
/// Identity property /// Identity property
#[dbus_proxy(property)] #[zbus(property)]
fn identity(&self) -> zbus::Result<String>; fn identity(&self) -> zbus::Result<String>;
/// SupportedMimeTypes property /// SupportedMimeTypes property
#[dbus_proxy(property)] #[zbus(property)]
fn supported_mime_types(&self) -> zbus::Result<Vec<String>>; fn supported_mime_types(&self) -> zbus::Result<Vec<String>>;
/// SupportedUriSchemes property /// SupportedUriSchemes property
#[dbus_proxy(property)] #[zbus(property)]
fn supported_uri_schemes(&self) -> zbus::Result<Vec<String>>; 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. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use crate::track::TrackId; use crate::track::TrackId;
use zbus::dbus_proxy; use zbus::proxy;
#[dbus_proxy( #[proxy(
interface = "org.mpris.MediaPlayer2.Player", interface = "org.mpris.MediaPlayer2.Player",
default_path = "/org/mpris/MediaPlayer2" default_path = "/org/mpris/MediaPlayer2"
)] )]
@ -56,76 +56,76 @@ trait Player {
fn stop(&self) -> zbus::Result<()>; fn stop(&self) -> zbus::Result<()>;
/// Seeked signal /// Seeked signal
#[dbus_proxy(signal)] #[zbus(signal)]
fn seeked(&self, position: i64) -> zbus::Result<()>; fn seeked(&self, position: i64) -> zbus::Result<()>;
/// CanControl property /// CanControl property
#[dbus_proxy(property)] #[zbus(property)]
fn can_control(&self) -> zbus::Result<bool>; fn can_control(&self) -> zbus::Result<bool>;
/// CanGoNext property /// CanGoNext property
#[dbus_proxy(property)] #[zbus(property)]
fn can_go_next(&self) -> zbus::Result<bool>; fn can_go_next(&self) -> zbus::Result<bool>;
/// CanGoPrevious property /// CanGoPrevious property
#[dbus_proxy(property)] #[zbus(property)]
fn can_go_previous(&self) -> zbus::Result<bool>; fn can_go_previous(&self) -> zbus::Result<bool>;
/// CanPause property /// CanPause property
#[dbus_proxy(property)] #[zbus(property)]
fn can_pause(&self) -> zbus::Result<bool>; fn can_pause(&self) -> zbus::Result<bool>;
/// CanPlay property /// CanPlay property
#[dbus_proxy(property)] #[zbus(property)]
fn can_play(&self) -> zbus::Result<bool>; fn can_play(&self) -> zbus::Result<bool>;
/// CanSeek property /// CanSeek property
#[dbus_proxy(property)] #[zbus(property)]
fn can_seek(&self) -> zbus::Result<bool>; fn can_seek(&self) -> zbus::Result<bool>;
/// MaximumRate property /// MaximumRate property
#[dbus_proxy(property)] #[zbus(property)]
fn maximum_rate(&self) -> zbus::Result<f64>; fn maximum_rate(&self) -> zbus::Result<f64>;
/// Metadata property /// Metadata property
#[dbus_proxy(property)] #[zbus(property)]
fn metadata( fn metadata(
&self, &self,
) -> zbus::Result<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>; ) -> zbus::Result<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>;
/// MinimumRate property /// MinimumRate property
#[dbus_proxy(property)] #[zbus(property)]
fn minimum_rate(&self) -> zbus::Result<f64>; fn minimum_rate(&self) -> zbus::Result<f64>;
/// PlaybackStatus property /// PlaybackStatus property
#[dbus_proxy(property)] #[zbus(property)]
fn playback_status(&self) -> zbus::Result<String>; fn playback_status(&self) -> zbus::Result<String>;
/// Position property /// Position property
#[dbus_proxy(property)] #[zbus(property)]
fn position(&self) -> zbus::Result<i64>; fn position(&self) -> zbus::Result<i64>;
/// Rate property /// Rate property
#[dbus_proxy(property)] #[zbus(property)]
fn rate(&self) -> zbus::Result<f64>; fn rate(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)] #[zbus(property)]
fn set_rate(&self, value: f64) -> zbus::Result<()>; fn set_rate(&self, value: f64) -> zbus::Result<()>;
/// Shuffle property (optional) /// Shuffle property (optional)
#[dbus_proxy(property)] #[zbus(property)]
fn shuffle(&self) -> zbus::Result<bool>; fn shuffle(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)] #[zbus(property)]
fn set_shuffle(&self, value: bool) -> zbus::Result<()>; fn set_shuffle(&self, value: bool) -> zbus::Result<()>;
/// LoopStatus property (optional) /// LoopStatus property (optional)
#[dbus_proxy(property)] #[zbus(property)]
fn loop_status(&self) -> zbus::Result<String>; fn loop_status(&self) -> zbus::Result<String>;
#[dbus_proxy(property)] #[zbus(property)]
fn set_loop_status(&self, value: String) -> zbus::Result<()>; fn set_loop_status(&self, value: String) -> zbus::Result<()>;
/// Volume property /// Volume property
#[dbus_proxy(property)] #[zbus(property)]
fn volume(&self) -> zbus::Result<f64>; fn volume(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)] #[zbus(property)]
fn set_volume(&self, value: f64) -> zbus::Result<()>; 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. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use crate::playlists::{id::PlaylistId, ordering::PlaylistOrdering, playlist::Playlist}; use crate::playlists::{id::PlaylistId, ordering::PlaylistOrdering, playlist::Playlist};
use zbus::dbus_proxy; use zbus::proxy;
#[dbus_proxy( #[proxy(
interface = "org.mpris.MediaPlayer2.Playlists", interface = "org.mpris.MediaPlayer2.Playlists",
default_path = "/org/mpris/MediaPlayer2" default_path = "/org/mpris/MediaPlayer2"
)] )]
@ -40,18 +40,18 @@ trait Playlists {
) -> zbus::Result<Vec<Playlist>>; ) -> zbus::Result<Vec<Playlist>>;
/// PlaylistChanged signal /// PlaylistChanged signal
#[dbus_proxy(signal)] #[zbus(signal)]
fn playlist_changed(&self, playlist: Playlist) -> zbus::Result<()>; fn playlist_changed(&self, playlist: Playlist) -> zbus::Result<()>;
/// ActivePlaylist property /// ActivePlaylist property
#[dbus_proxy(property)] #[zbus(property)]
fn active_playlist(&self) -> zbus::Result<(bool, Playlist)>; fn active_playlist(&self) -> zbus::Result<(bool, Playlist)>;
/// Orderings property /// Orderings property
#[dbus_proxy(property)] #[zbus(property)]
fn orderings(&self) -> zbus::Result<Vec<String>>; fn orderings(&self) -> zbus::Result<Vec<String>>;
/// PlaylistCount property /// PlaylistCount property
#[dbus_proxy(property)] #[zbus(property)]
fn playlist_count(&self) -> zbus::Result<u32>; fn playlist_count(&self) -> zbus::Result<u32>;
} }

View file

@ -20,9 +20,9 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use crate::track::TrackId; use crate::track::TrackId;
use zbus::dbus_proxy; use zbus::proxy;
#[dbus_proxy( #[proxy(
interface = "org.mpris.MediaPlayer2.TrackList", interface = "org.mpris.MediaPlayer2.TrackList",
default_path = "/org/mpris/MediaPlayer2" default_path = "/org/mpris/MediaPlayer2"
)] )]
@ -44,15 +44,15 @@ trait TrackList {
fn remove_track(&self, track_id: &TrackId) -> zbus::Result<()>; fn remove_track(&self, track_id: &TrackId) -> zbus::Result<()>;
/// TrackListReplaced signal /// TrackListReplaced signal
#[dbus_proxy(signal)] #[zbus(signal)]
fn track_list_replaced(&self, tracks: Vec<TrackId>, current_track: TrackId) fn track_list_replaced(&self, tracks: Vec<TrackId>, current_track: TrackId)
-> zbus::Result<()>; -> zbus::Result<()>;
/// CanEditTracks property /// CanEditTracks property
#[dbus_proxy(property)] #[zbus(property)]
fn can_edit_tracks(&self) -> zbus::Result<bool>; fn can_edit_tracks(&self) -> zbus::Result<bool>;
/// Tracks property /// Tracks property
#[dbus_proxy(property)] #[zbus(property)]
fn tracks(&self) -> zbus::Result<Vec<TrackId>>; 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. /// Returns an instance to the `org.mpris.MediaPlayer2.Player` interface of this object.
pub async fn player(&self) -> Result<Player> { pub async fn player(&self) -> Result<Player> {
PlayerProxy::builder(self.proxy.connection()) PlayerProxy::builder(self.proxy.inner().connection())
.destination(self.proxy.destination().to_owned())? .destination(self.proxy.inner().destination().to_owned())?
.build() .build()
.await .await
.map(Player::from) .map(Player::from)
@ -58,8 +58,8 @@ impl MediaPlayer {
/// if a track list is available. /// if a track list is available.
pub async fn track_list(&self) -> Result<Option<TrackList>> { pub async fn track_list(&self) -> Result<Option<TrackList>> {
if self.proxy.has_track_list().await? { if self.proxy.has_track_list().await? {
TrackListProxy::builder(self.proxy.connection()) TrackListProxy::builder(self.proxy.inner().connection())
.destination(self.proxy.destination().to_owned())? .destination(self.proxy.inner().destination().to_owned())?
.build() .build()
.await .await
.map(TrackList::from) .map(TrackList::from)
@ -74,8 +74,8 @@ impl MediaPlayer {
/// if a track list is available. /// if a track list is available.
pub async fn playlists(&self) -> Result<Option<Playlists>> { pub async fn playlists(&self) -> Result<Option<Playlists>> {
if self.proxy.has_track_list().await? { if self.proxy.has_track_list().await? {
PlaylistsProxy::builder(self.proxy.connection()) PlaylistsProxy::builder(self.proxy.inner().connection())
.destination(self.proxy.destination().to_owned())? .destination(self.proxy.inner().destination().to_owned())?
.build() .build()
.await .await
.map(Playlists::from) .map(Playlists::from)

View file

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

View file

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

View file

@ -8,7 +8,7 @@ use std::{
fmt::{self, Display}, fmt::{self, Display},
str::FromStr, str::FromStr,
}; };
use zvariant::{OwnedValue, Signature, Type, Value}; use zvariant::{Signature, Type, Value};
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum PlaylistOrdering { pub enum PlaylistOrdering {
@ -38,7 +38,9 @@ impl<'a> TryFrom<Value<'a>> for PlaylistOrdering {
Value::Str(value) => Self::from_str(&value), Value::Str(value) => Self::from_str(&value),
_ => Err(Error::IncorrectValue { _ => Err(Error::IncorrectValue {
wanted: "Str", 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 devices = self.0.devices().await?;
let mut out = Vec::with_capacity(devices.len()); let mut out = Vec::with_capacity(devices.len());
for device in devices { for device in devices {
let device = DeviceProxy::builder(self.0.connection()) let device = DeviceProxy::builder(self.0.inner().connection())
.path(device)? .path(device)?
.build() .build()
.await?; .await?;
@ -31,7 +31,7 @@ impl<'a> ActiveConnection<'a> {
} }
pub async fn ip4_config(&self) -> Result<Ipv4Config<'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?)? .path(self.0.ip4_config().await?)?
.build() .build()
.await?; .await?;
@ -39,7 +39,7 @@ impl<'a> ActiveConnection<'a> {
} }
pub async fn ip6_config(&self) -> Result<Ipv6Config<'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?)? .path(self.0.ip6_config().await?)?
.build() .build()
.await?; .await?;

View file

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

View file

@ -29,7 +29,7 @@ impl<'a> Ipv6Config<'a> {
.filter_map(|mut map| { .filter_map(|mut map| {
let address = { let address = {
let address_str = map.remove("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()? Ipv6Addr::from_str(address_str).ok()?
}; };
let prefix = u32::try_from(map.remove("prefix")?).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> { impl<'a> Device<'a> {
pub async fn active_connection(&self) -> Result<ActiveConnection<'a>> { pub async fn active_connection(&self) -> Result<ActiveConnection<'a>> {
let active_connection = self.0.active_connection().await?; let active_connection = self.0.active_connection().await?;
Ok(ActiveConnectionProxy::builder(self.0.connection()) Ok(ActiveConnectionProxy::builder(self.0.inner().connection())
.path(active_connection)? .path(active_connection)?
.build() .build()
.await? .await?
@ -39,7 +39,7 @@ impl<'a> Device<'a> {
let available_connections = self.0.available_connections().await?; let available_connections = self.0.available_connections().await?;
let mut out = Vec::with_capacity(available_connections.len()); let mut out = Vec::with_capacity(available_connections.len());
for connection in available_connections { for connection in available_connections {
let connection = ActiveConnectionProxy::builder(self.0.connection()) let connection = ActiveConnectionProxy::builder(self.0.inner().connection())
.path(connection)? .path(connection)?
.build() .build()
.await?; .await?;
@ -62,36 +62,36 @@ impl<'a> Device<'a> {
pub async fn downcast_to_device(&'a self) -> Result<Option<SpecificDevice<'a>>> { pub async fn downcast_to_device(&'a self) -> Result<Option<SpecificDevice<'a>>> {
match self.device_type().await? { match self.device_type().await? {
DeviceType::Bluetooth => Ok(Some(SpecificDevice::Bluetooth( DeviceType::Bluetooth => Ok(Some(SpecificDevice::Bluetooth(
BluetoothDeviceProxy::builder(self.0.connection()) BluetoothDeviceProxy::builder(self.0.inner().connection())
.path(self.0.path())? .path(self.0.inner().path())?
.build() .build()
.await? .await?
.into(), .into(),
))), ))),
DeviceType::Ethernet => Ok(Some(SpecificDevice::Wired( DeviceType::Ethernet => Ok(Some(SpecificDevice::Wired(
WiredDeviceProxy::builder(self.0.connection()) WiredDeviceProxy::builder(self.0.inner().connection())
.path(self.0.path())? .path(self.0.inner().path())?
.build() .build()
.await? .await?
.into(), .into(),
))), ))),
DeviceType::Wifi => Ok(Some(SpecificDevice::Wireless( DeviceType::Wifi => Ok(Some(SpecificDevice::Wireless(
WirelessDeviceProxy::builder(self.0.connection()) WirelessDeviceProxy::builder(self.0.inner().connection())
.path(self.0.path())? .path(self.0.inner().path())?
.build() .build()
.await? .await?
.into(), .into(),
))), ))),
DeviceType::TunTap => Ok(Some(SpecificDevice::TunTap( DeviceType::TunTap => Ok(Some(SpecificDevice::TunTap(
TunDeviceProxy::builder(self.0.connection()) TunDeviceProxy::builder(self.0.inner().connection())
.path(self.0.path())? .path(self.0.inner().path())?
.build() .build()
.await? .await?
.into(), .into(),
))), ))),
DeviceType::WireGuard => Ok(Some(SpecificDevice::WireGuard( DeviceType::WireGuard => Ok(Some(SpecificDevice::WireGuard(
WireGuardDeviceProxy::builder(self.0.connection()) WireGuardDeviceProxy::builder(self.0.inner().connection())
.path(self.0.path())? .path(self.0.inner().path())?
.build() .build()
.await? .await?
.into(), .into(),
@ -105,7 +105,7 @@ impl<'a> Device<'a> {
} }
pub async fn ip4_config(&self) -> Result<Ipv4Config<'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?)? .path(self.0.ip4_config().await?)?
.build() .build()
.await?; .await?;
@ -113,7 +113,7 @@ impl<'a> Device<'a> {
} }
pub async fn ip6_config(&self) -> Result<Ipv6Config<'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?)? .path(self.0.ip6_config().await?)?
.build() .build()
.await?; .await?;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,22 +11,22 @@
//! section of the zbus documentation. //! section of the zbus documentation.
//! //!
use zbus::dbus_proxy; use zbus::proxy;
#[dbus_proxy( #[proxy(
interface = "org.freedesktop.NetworkManager.Device.WireGuard", interface = "org.freedesktop.NetworkManager.Device.WireGuard",
default_service = "org.freedesktop.NetworkManager" default_service = "org.freedesktop.NetworkManager"
)] )]
pub trait WireGuardDevice { pub trait WireGuardDevice {
/// FwMark property /// FwMark property
#[dbus_proxy(property)] #[zbus(property)]
fn fw_mark(&self) -> zbus::Result<u32>; fn fw_mark(&self) -> zbus::Result<u32>;
/// ListenPort property /// ListenPort property
#[dbus_proxy(property)] #[zbus(property)]
fn listen_port(&self) -> zbus::Result<u16>; fn listen_port(&self) -> zbus::Result<u16>;
/// PublicKey property /// PublicKey property
#[dbus_proxy(property)] #[zbus(property)]
fn public_key(&self) -> zbus::Result<Vec<u8>>; 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. //! …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", interface = "org.freedesktop.NetworkManager.Device.Wireless",
default_service = "org.freedesktop.NetworkManager" default_service = "org.freedesktop.NetworkManager"
)] )]
@ -40,45 +40,45 @@ pub trait WirelessDevice {
) -> zbus::Result<()>; ) -> zbus::Result<()>;
/// AccessPointAdded signal /// AccessPointAdded signal
#[dbus_proxy(signal)] #[zbus(signal)]
fn access_point_added(&self, access_point: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>; fn access_point_added(&self, access_point: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
/// AccessPointRemoved signal /// AccessPointRemoved signal
#[dbus_proxy(signal)] #[zbus(signal)]
fn access_point_removed( fn access_point_removed(
&self, &self,
access_point: zbus::zvariant::ObjectPath<'_>, access_point: zbus::zvariant::ObjectPath<'_>,
) -> zbus::Result<()>; ) -> zbus::Result<()>;
/// AccessPoints property /// AccessPoints property
#[dbus_proxy(property)] #[zbus(property)]
fn access_points(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>; fn access_points(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
/// ActiveAccessPoint property /// ActiveAccessPoint property
#[dbus_proxy(property)] #[zbus(property)]
fn active_access_point(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>; fn active_access_point(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
/// Bitrate property /// Bitrate property
#[dbus_proxy(property)] #[zbus(property)]
fn bitrate(&self) -> zbus::Result<u32>; fn bitrate(&self) -> zbus::Result<u32>;
/// HwAddress property /// HwAddress property
#[dbus_proxy(property)] #[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>; fn hw_address(&self) -> zbus::Result<String>;
/// LastScan property /// LastScan property
#[dbus_proxy(property)] #[zbus(property)]
fn last_scan(&self) -> zbus::Result<i64>; fn last_scan(&self) -> zbus::Result<i64>;
/// Mode property /// Mode property
#[dbus_proxy(property)] #[zbus(property)]
fn mode(&self) -> zbus::Result<u32>; fn mode(&self) -> zbus::Result<u32>;
/// PermHwAddress property /// PermHwAddress property
#[dbus_proxy(property)] #[zbus(property)]
fn perm_hw_address(&self) -> zbus::Result<String>; fn perm_hw_address(&self) -> zbus::Result<String>;
/// WirelessCapabilities property /// WirelessCapabilities property
#[dbus_proxy(property)] #[zbus(property)]
fn wireless_capabilities(&self) -> zbus::Result<u32>; fn wireless_capabilities(&self) -> zbus::Result<u32>;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -42,7 +42,7 @@ macro_rules! derive_value_build {
ret 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(); let mut out = std::collections::HashMap::new();
$( $(
if let Some(val) = &self.$arg { if let Some(val) = &self.$arg {

View file

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

View file

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

View file

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

View file

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

View file

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