fix deprecation warnings caused by old trait object syntax

This commit is contained in:
Henrik Friedrichsen
2019-09-01 01:32:50 +02:00
parent 9a38eaa535
commit 7aa70fcb6b
10 changed files with 27 additions and 25 deletions

View File

@@ -150,7 +150,7 @@ impl ListItem for Album {
}
}
fn as_listitem(&self) -> Box<ListItem> {
fn as_listitem(&self) -> Box<dyn ListItem> {
Box::new(self.clone())
}

View File

@@ -139,7 +139,7 @@ impl ListItem for Artist {
}
}
fn as_listitem(&self) -> Box<ListItem> {
fn as_listitem(&self) -> Box<dyn ListItem> {
Box::new(self.clone())
}

View File

@@ -12,7 +12,7 @@ use queue::{Queue, RepeatSetting};
use spotify::{PlayerEvent, Spotify};
use track::Track;
type Metadata = HashMap<String, Variant<Box<RefArg>>>;
type Metadata = HashMap<String, Variant<Box<dyn RefArg>>>;
struct MprisState(String, Option<Track>);
fn get_playbackstatus(spotify: Arc<Spotify>) -> String {
@@ -192,7 +192,7 @@ fn run_dbus_server(spotify: Arc<Spotify>, queue: Arc<Queue>, rx: mpsc::Receiver<
let property_metadata = {
let queue = queue.clone();
f.property::<HashMap<String, Variant<Box<RefArg>>>, _>("Metadata", ())
f.property::<HashMap<String, Variant<Box<dyn RefArg>>>, _>("Metadata", ())
.access(Access::Read)
.on_get(move |iter, _| {
let hm = get_metadata(queue.clone().get_current());
@@ -401,7 +401,10 @@ fn run_dbus_server(spotify: Arc<Spotify>, queue: Arc<Queue>, rx: mpsc::Receiver<
if let Ok(state) = rx.try_recv() {
let mut changed: PropertiesPropertiesChanged = Default::default();
debug!("mpris PropertiesChanged: status {}, track: {:?}", state.0, state.1);
debug!(
"mpris PropertiesChanged: status {}, track: {:?}",
state.0, state.1
);
changed.interface_name = "org.mpris.MediaPlayer2.Player".to_string();
changed.changed_properties.insert(
@@ -409,15 +412,14 @@ fn run_dbus_server(spotify: Arc<Spotify>, queue: Arc<Queue>, rx: mpsc::Receiver<
Variant(Box::new(get_metadata(state.1))),
);
changed.changed_properties.insert(
"PlaybackStatus".to_string(),
Variant(Box::new(state.0)),
);
changed
.changed_properties
.insert("PlaybackStatus".to_string(), Variant(Box::new(state.0)));
conn.send(
changed.to_emit_message(&Path::new("/org/mpris/MediaPlayer2".to_string()).unwrap()),
)
.unwrap();
.unwrap();
}
}
}
@@ -426,7 +428,7 @@ fn run_dbus_server(spotify: Arc<Spotify>, queue: Arc<Queue>, rx: mpsc::Receiver<
pub struct MprisManager {
tx: mpsc::Sender<MprisState>,
queue: Arc<Queue>,
spotify: Arc<Spotify>
spotify: Arc<Spotify>,
}
impl MprisManager {

View File

@@ -107,7 +107,7 @@ impl ListItem for Playlist {
}
}
fn as_listitem(&self) -> Box<ListItem> {
fn as_listitem(&self) -> Box<dyn ListItem> {
Box::new(self.clone())
}

View File

@@ -75,9 +75,9 @@ struct Worker {
commands: mpsc::UnboundedReceiver<WorkerCommand>,
session: Session,
player: Player,
play_task: Box<futures::Future<Item = (), Error = oneshot::Canceled>>,
refresh_task: Box<futures::Stream<Item = (), Error = tokio_timer::Error>>,
token_task: Box<futures::Future<Item = (), Error = MercuryError>>,
play_task: Box<dyn futures::Future<Item = (), Error = oneshot::Canceled>>,
refresh_task: Box<dyn futures::Stream<Item = (), Error = tokio_timer::Error>>,
token_task: Box<dyn futures::Future<Item = (), Error = MercuryError>>,
active: bool,
}
@@ -102,7 +102,7 @@ impl Worker {
}
impl Worker {
fn create_refresh(&self) -> Box<futures::Stream<Item = (), Error = tokio_timer::Error>> {
fn create_refresh(&self) -> Box<dyn futures::Stream<Item = (), Error = tokio_timer::Error>> {
let ev = self.events.clone();
let future =
tokio_timer::Interval::new_interval(Duration::from_millis(400)).map(move |_| {
@@ -185,8 +185,8 @@ impl futures::Future for Worker {
}
Err(e) => {
error!("could not generate token: {:?}", e);
},
_ => ()
}
_ => (),
}
if !progress {
@@ -256,7 +256,7 @@ impl Spotify {
fn get_token(
session: &Session,
sender: oneshot::Sender<Token>,
) -> Box<Future<Item = (), Error = MercuryError>> {
) -> Box<dyn Future<Item = (), Error = MercuryError>> {
let client_id = config::CLIENT_ID;
let scopes = "user-read-private,playlist-read-private,playlist-read-collaborative,playlist-modify-public,playlist-modify-private,user-follow-modify,user-follow-read,user-library-read,user-library-modify,user-top-read,user-read-recently-played";
let url = format!(

View File

@@ -151,7 +151,7 @@ impl ListItem for Track {
current.map(|t| t.id == self.id).unwrap_or(false)
}
fn as_listitem(&self) -> Box<ListItem> {
fn as_listitem(&self) -> Box<dyn ListItem> {
Box::new(self.clone())
}

View File

@@ -31,7 +31,7 @@ pub trait ListItem: Sync + Send + 'static {
None
}
fn as_listitem(&self) -> Box<ListItem>;
fn as_listitem(&self) -> Box<dyn ListItem>;
}
pub trait ViewExt: View {

View File

@@ -17,12 +17,12 @@ pub struct ContextMenu {
}
enum ContextMenuAction {
ShowItem(Box<ListItem>),
ShowItem(Box<dyn ListItem>),
ShareUrl(String),
}
impl ContextMenu {
pub fn new(item: &Box<ListItem>, queue: Arc<Queue>, library: Arc<Library>) -> Self {
pub fn new(item: &Box<dyn ListItem>, queue: Arc<Queue>, library: Arc<Library>) -> Self {
let mut content: SelectView<ContextMenuAction> = SelectView::new().autojump();
if let Some(a) = item.artist() {
content.add_item("Show artist", ContextMenuAction::ShowItem(Box::new(a)));

View File

@@ -21,7 +21,7 @@ use ui::album::AlbumView;
use ui::artist::ArtistView;
use ui::contextmenu::ContextMenu;
pub type Paginator<I> = Box<Fn(Arc<RwLock<Vec<I>>>) + Send + Sync>;
pub type Paginator<I> = Box<dyn Fn(Arc<RwLock<Vec<I>>>) + Send + Sync>;
pub struct Pagination<I: ListItem> {
max_content: Arc<RwLock<Option<usize>>>,
callback: Arc<RwLock<Option<Paginator<I>>>>,

View File

@@ -40,7 +40,7 @@ pub struct SearchView {
}
type SearchHandler<I> =
Box<Fn(&Arc<Spotify>, &Arc<RwLock<Vec<I>>>, &str, usize, bool) -> u32 + Send + Sync>;
Box<dyn Fn(&Arc<Spotify>, &Arc<RwLock<Vec<I>>>, &str, usize, bool) -> u32 + Send + Sync>;
pub const LIST_ID: &str = "search_list";
pub const EDIT_ID: &str = "search_edit";