Skip to content

Commit

Permalink
feat!: drop async_trait usage
Browse files Browse the repository at this point in the history
Replace with native async function in trait

Closes #4
  • Loading branch information
SeaDve committed Jan 27, 2024
1 parent b44b0a5 commit 8cd2627
Show file tree
Hide file tree
Showing 8 changed files with 1,069 additions and 1,157 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ license = "MPL-2.0"
edition = "2021"

[dependencies]
async-trait = "0.1"
futures-channel = "0.3"
futures-util = { version = "0.3", default-features = false, features = ["std"] }
serde = "1.0"
trait-variant = "0.1.1"
zbus = "3.14"

[dev-dependencies]
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ It is recommended to manually create your own implementation of the interfaces i
use std::future;
use mpris_server::{
async_trait,
zbus::{fdo, Result},
Metadata, PlayerInterface, Property, RootInterface, Server, Signal, Time, Volume,
};
pub struct MyPlayer;
#[async_trait]
impl RootInterface for MyPlayer {
async fn identity(&self) -> fdo::Result<String> {
Ok("MyPlayer".into())
Expand All @@ -54,7 +52,6 @@ impl RootInterface for MyPlayer {
// Other methods...
}
#[async_trait]
impl PlayerInterface for MyPlayer {
async fn set_volume(&self, volume: Volume) -> Result<()> {
self.volume.set(volume);
Expand Down
5 changes: 0 additions & 5 deletions examples/local_server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::future;

use mpris_server::{
async_trait,
zbus::{fdo, Result},
LocalPlayerInterface, LocalPlaylistsInterface, LocalRootInterface, LocalServer,
LocalTrackListInterface, LoopStatus, Metadata, PlaybackRate, PlaybackStatus, Playlist,
Expand All @@ -10,7 +9,6 @@ use mpris_server::{

pub struct Player;

#[async_trait(?Send)]
impl LocalRootInterface for Player {
async fn raise(&self) -> fdo::Result<()> {
println!("Raise");
Expand Down Expand Up @@ -73,7 +71,6 @@ impl LocalRootInterface for Player {
}
}

#[async_trait(?Send)]
impl LocalPlayerInterface for Player {
async fn next(&self) -> fdo::Result<()> {
println!("Next");
Expand Down Expand Up @@ -216,7 +213,6 @@ impl LocalPlayerInterface for Player {
}
}

#[async_trait(?Send)]
impl LocalTrackListInterface for Player {
async fn get_tracks_metadata(&self, track_ids: Vec<TrackId>) -> fdo::Result<Vec<Metadata>> {
println!("GetTracksMetadata({:?})", track_ids);
Expand Down Expand Up @@ -254,7 +250,6 @@ impl LocalTrackListInterface for Player {
}
}

#[async_trait(?Send)]
impl LocalPlaylistsInterface for Player {
async fn activate_playlist(&self, playlist_id: PlaylistId) -> fdo::Result<()> {
println!("ActivatePlaylist({})", playlist_id);
Expand Down
5 changes: 0 additions & 5 deletions examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::future;

use mpris_server::{
async_trait,
zbus::{fdo, Result},
LoopStatus, Metadata, PlaybackRate, PlaybackStatus, PlayerInterface, Playlist, PlaylistId,
PlaylistOrdering, PlaylistsInterface, Property, RootInterface, Server, Signal, Time, TrackId,
Expand All @@ -10,7 +9,6 @@ use mpris_server::{

pub struct Player;

#[async_trait]
impl RootInterface for Player {
async fn raise(&self) -> fdo::Result<()> {
println!("Raise");
Expand Down Expand Up @@ -73,7 +71,6 @@ impl RootInterface for Player {
}
}

#[async_trait]
impl PlayerInterface for Player {
async fn next(&self) -> fdo::Result<()> {
println!("Next");
Expand Down Expand Up @@ -216,7 +213,6 @@ impl PlayerInterface for Player {
}
}

#[async_trait]
impl TrackListInterface for Player {
async fn get_tracks_metadata(&self, track_ids: Vec<TrackId>) -> fdo::Result<Vec<Metadata>> {
println!("GetTracksMetadata({:?})", track_ids);
Expand Down Expand Up @@ -254,7 +250,6 @@ impl TrackListInterface for Player {
}
}

#[async_trait]
impl PlaylistsInterface for Player {
async fn activate_playlist(&self, playlist_id: PlaylistId) -> fdo::Result<()> {
println!("ActivatePlaylist({})", playlist_id);
Expand Down
Loading

0 comments on commit 8cd2627

Please sign in to comment.