feat: zbus 4.2.1 update
This commit is contained in:
parent
ce9c789fe6
commit
f05789c4ce
42 changed files with 390 additions and 389 deletions
|
|
@ -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>>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<()>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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)))?,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue