@@ -5,7 +5,7 @@ use log::{debug, info, warn};
55use thiserror:: Error ;
66use time:: format_description:: well_known:: Iso8601 ;
77use tokio:: sync:: mpsc;
8- use zbus:: connection;
8+ use zbus:: { connection, fdo } ;
99
1010use librespot:: {
1111 core:: date:: Date ,
@@ -621,16 +621,14 @@ impl MprisPlayerService {
621621 // Calling Play after this should cause playback to start again from the same position.
622622 //
623623 // If `self.can_pause` is `false`, attempting to call this method should have no effect.
624- async fn pause ( & self ) -> zbus :: fdo:: Result < ( ) > {
624+ async fn pause ( & self ) -> fdo:: Result < ( ) > {
625625 debug ! ( "org.mpris.MediaPlayer2.Player::Pause" ) ;
626626 match ( & self . spirc , & self . metadata . mpris . track_id ) {
627627 ( Some ( spirc) , Some ( _) ) => spirc
628628 . pause ( )
629- . map_err ( |err| zbus:: fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
630- ( Some ( _) , None ) => {
631- zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "No track" ) ) )
632- }
633- _ => zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
629+ . map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
630+ ( Some ( _) , None ) => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "No track" ) ) ) ,
631+ _ => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
634632 }
635633 }
636634
@@ -642,16 +640,14 @@ impl MprisPlayerService {
642640 //
643641 // If `self.can_pause` is `false`, attempting to call this method should have no effect and
644642 // raise an error.
645- async fn play_pause ( & self ) -> zbus :: fdo:: Result < ( ) > {
643+ async fn play_pause ( & self ) -> fdo:: Result < ( ) > {
646644 debug ! ( "org.mpris.MediaPlayer2.Player::PlayPause" ) ;
647645 match ( & self . spirc , & self . metadata . mpris . track_id ) {
648646 ( Some ( spirc) , Some ( _) ) => spirc
649647 . play_pause ( )
650- . map_err ( |err| zbus:: fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
651- ( Some ( _) , None ) => {
652- zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "No track" ) ) )
653- }
654- _ => zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
648+ . map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
649+ ( Some ( _) , None ) => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "No track" ) ) ) ,
650+ _ => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
655651 }
656652 }
657653
@@ -681,7 +677,7 @@ impl MprisPlayerService {
681677 // If there is no track to play, this has no effect.
682678 //
683679 // If `self.can_play` is `false`, attempting to call this method should have no effect.
684- async fn play ( & self ) -> zbus :: fdo:: Result < ( ) > {
680+ async fn play ( & self ) -> fdo:: Result < ( ) > {
685681 debug ! ( "org.mpris.MediaPlayer2.Player::Play" ) ;
686682 if let Some ( spirc) = & self . spirc {
687683 let _ = spirc. activate ( ) ;
@@ -693,12 +689,10 @@ impl MprisPlayerService {
693689 spirc. activate ( ) ?;
694690 spirc. play ( )
695691 } ) ( ) ;
696- result. map_err ( |err| zbus:: fdo:: Error :: Failed ( format ! ( "{err}" ) ) )
697- }
698- ( Some ( _) , None ) => {
699- zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "No track" ) ) )
692+ result. map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) )
700693 }
701- _ => zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
694+ ( Some ( _) , None ) => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "No track" ) ) ) ,
695+ _ => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
702696 }
703697 }
704698
@@ -785,11 +779,9 @@ impl MprisPlayerService {
785779 // * `uri`: Uri of the track to load. Its uri scheme should be an element of the
786780 // `org.mpris.MediaPlayer2.SupportedUriSchemes` property and the mime-type should
787781 // match one of the elements of the `org.mpris.MediaPlayer2.SupportedMimeTypes`.
788- async fn open_uri ( & self , uri : & str ) -> zbus :: fdo:: Result < ( ) > {
782+ async fn open_uri ( & self , uri : & str ) -> fdo:: Result < ( ) > {
789783 debug ! ( "org.mpris.MediaPlayer2.Player::OpenUri({uri:?})" ) ;
790- Err ( zbus:: fdo:: Error :: NotSupported (
791- "OpenUri not supported" . to_owned ( ) ,
792- ) )
784+ Err ( fdo:: Error :: NotSupported ( "OpenUri not supported" . to_owned ( ) ) )
793785 }
794786
795787 // The current playback status.
@@ -818,7 +810,7 @@ impl MprisPlayerService {
818810 }
819811
820812 #[ zbus( property) ]
821- async fn set_loop_status ( & mut self , value : LoopStatus ) -> zbus :: fdo:: Result < ( ) > {
813+ async fn set_loop_status ( & mut self , value : LoopStatus ) -> fdo:: Result < ( ) > {
822814 debug ! ( "org.mpris.MediaPlayer2.Player::LoopStatus({value:?})" ) ;
823815 match value {
824816 LoopStatus :: None => {
@@ -904,12 +896,9 @@ impl MprisPlayerService {
904896 #[ zbus( property( emits_changed_signal = "true" ) ) ]
905897 async fn metadata (
906898 & self ,
907- ) -> zbus :: fdo:: Result < std:: collections:: HashMap < String , zbus:: zvariant:: OwnedValue > > {
899+ ) -> fdo:: Result < std:: collections:: HashMap < String , zbus:: zvariant:: OwnedValue > > {
908900 debug ! ( "org.mpris.MediaPlayer2.Player::Metadata" ) ;
909- self . metadata
910- . clone ( )
911- . try_into ( )
912- . map_err ( zbus:: fdo:: Error :: ZBus )
901+ self . metadata . clone ( ) . try_into ( ) . map_err ( fdo:: Error :: ZBus )
913902 }
914903
915904 // The volume level.
@@ -925,7 +914,7 @@ impl MprisPlayerService {
925914 }
926915
927916 #[ zbus( property) ]
928- async fn set_volume ( & mut self , value : Volume ) -> zbus :: fdo:: Result < ( ) > {
917+ async fn set_volume ( & mut self , value : Volume ) -> fdo:: Result < ( ) > {
929918 debug ! ( "org.mpris.MediaPlayer2.Player::Volume({value})" ) ;
930919 if let Some ( spirc) = & self . spirc {
931920 // As of rust 1.45, cast is guaranteed to round to 0 and saturate.
@@ -934,7 +923,7 @@ impl MprisPlayerService {
934923 let mapped_volume = ( value * ( u16:: MAX as f64 ) ) . round ( ) as u16 ;
935924 spirc
936925 . set_volume ( mapped_volume)
937- . map_err ( |err| zbus :: fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ?;
926+ . map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ?;
938927 }
939928 Ok ( ( ) )
940929 }
@@ -949,7 +938,7 @@ impl MprisPlayerService {
949938 // If the playback progresses in a way that is inconstistant with the `Rate` property, the
950939 // `Seeked` signal is emited.
951940 #[ zbus( property( emits_changed_signal = "false" ) ) ]
952- async fn position ( & self ) -> zbus :: fdo:: Result < TimeInUs > {
941+ async fn position ( & self ) -> fdo:: Result < TimeInUs > {
953942 debug ! ( "org.mpris.MediaPlayer2.Player::Position" ) ;
954943
955944 self . position
@@ -959,7 +948,7 @@ impl MprisPlayerService {
959948 . saturating_add ( position. last_update . elapsed ( ) . as_millis ( ) ) ;
960949 corrected as i64 * 1000
961950 } )
962- . ok_or ( zbus :: fdo:: Error :: Failed ( String :: from ( "Got no position" ) ) )
951+ . ok_or ( fdo:: Error :: Failed ( String :: from ( "Got no position" ) ) )
963952 }
964953
965954 // The minimum value which the `Rate` property can take. Clients should not attempt to set the
0 commit comments