cargo fmt

This commit is contained in:
Henrik Friedrichsen
2019-03-20 23:38:17 +01:00
parent cdf63ba9ac
commit c0e6f9ec34

View File

@@ -10,8 +10,8 @@ use librespot::playback::audio_backend;
use librespot::playback::config::Bitrate;
use librespot::playback::player::Player;
use rspotify::spotify::client::Spotify as SpotifyAPI;
use rspotify::spotify::client::ApiError;
use rspotify::spotify::client::Spotify as SpotifyAPI;
use rspotify::spotify::model::page::Page;
use rspotify::spotify::model::playlist::{PlaylistTrack, SimplifiedPlaylist};
use rspotify::spotify::model::search::SearchTracks;
@@ -284,7 +284,9 @@ impl Spotify {
/// retries once when rate limits are hit
fn api_with_retry<F, R>(&self, cb: F) -> Option<R>
where F: Fn(&SpotifyAPI) -> Result<R, Error> {
where
F: Fn(&SpotifyAPI) -> Result<R, Error>,
{
match cb(&self.api) {
Ok(v) => Some(v),
Err(e) => {
@@ -294,17 +296,19 @@ impl Spotify {
debug!("rate limit hit. waiting {:?} seconds", d);
thread::sleep(Duration::from_secs(d.unwrap_or(0) as u64));
cb(&self.api).ok()
} else {
None
}
else { None }
} else {
None
}
else { None }
}
}
}
pub fn search(&self, query: &str, limit: u32, offset: u32) -> Option<SearchTracks> {
//let res = self.api.search_track(query, limit, offset, None);
self.api_with_retry(|api| api.search_track(query, limit, offset, None) )
self.api_with_retry(|api| api.search_track(query, limit, offset, None))
}
pub fn current_user_playlist(
@@ -312,7 +316,7 @@ impl Spotify {
limit: u32,
offset: u32,
) -> Option<Page<SimplifiedPlaylist>> {
self.api_with_retry(|api| api.current_user_playlists(limit, offset) )
self.api_with_retry(|api| api.current_user_playlists(limit, offset))
}
pub fn user_playlist_tracks(
@@ -321,8 +325,9 @@ impl Spotify {
limit: u32,
offset: u32,
) -> Option<Page<PlaylistTrack>> {
self.api_with_retry(|api| api
.user_playlist_tracks(&self.user, playlist_id, None, limit, offset, None))
self.api_with_retry(|api| {
api.user_playlist_tracks(&self.user, playlist_id, None, limit, offset, None)
})
}
pub fn load(&self, track: &Track) {