Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish the pagination implementation #201

Merged
merged 13 commits into from
Apr 22, 2021
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,17 @@ If we missed any change or there's something you'd like to discuss about this ve
+ Change `OAuth.scope` from `String` to `HashSet`.
+ Change `SimplifiedPlaylist::tracks` from `HashMap` to `PlaylistTracksRef`
- ([#194](https://github.com/ramsayleung/rspotify/pull/194)) Rename `PlayingItem` to `PlayableItem`, `PlaylistItem::track` type changed to `Option<PlayableItem>`, so playlists can contain episodes as well
- ([#!97](https://github.com/ramsayleung/rspotify/pull/197)) Makeing acronym lowercase
- ([#197](https://github.com/ramsayleung/rspotify/pull/197)) Makeing acronym lowercase
+ Rename `ClientError::ParseJSON` to `ClientError::ParseJson`
+ Rename `ClientError::ParseURL` to `ClientError::ParseUrl`
+ Rename `ClientError::IO` to `ClientError::Io`
+ Rename `ClientError::CLI` to `ClientError::Cli`
+ Rename `BaseHTTPClient` to `BaseHttpClient`
- [#166](https://github.com/ramsayleung/rspotify/pull/166) [#201](https://github.com/ramsayleung/rspotify/pull/201) Add automatic pagination, which is now enabled by default. You can still use the methods with the `_manual` suffix to have access to manual pagination. There are three new examples for this, check out `examples/pagination*` to learn more!

As a side effect, some methods now take references instead of values (so that they can be used multiple times when querying), and the parameters have been reordered so that the `limit` and `offset` are consistently the last two.

The pagination chunk size can be configured with the `Spotify::pagination_chunks` field, which is set to 50 items by default.

## 0.10 (2020/07/01)

Expand Down
4 changes: 2 additions & 2 deletions examples/pagination_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ async fn main() {
spotify.prompt_for_user_token().await.unwrap();

// Executing the futures sequentially
let stream = spotify.current_user_saved_tracks_auto();
let stream = spotify.current_user_saved_tracks();
pin_mut!(stream);
println!("Items (blocking):");
while let Some(item) = stream.try_next().await.unwrap() {
println!("* {}", item.track.name);
}

// Executing the futures concurrently
let stream = spotify.current_user_saved_tracks_auto();
let stream = spotify.current_user_saved_tracks();
println!("\nItems (concurrent):");
stream
.try_for_each_concurrent(10, |item| async move {
Expand Down
2 changes: 1 addition & 1 deletion examples/pagination_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn main() {
println!("Items:");
loop {
let page = spotify
.current_user_saved_tracks(limit, offset)
.current_user_saved_tracks_manual(limit, offset)
.await
.unwrap();
for item in page.items {
Expand Down
2 changes: 1 addition & 1 deletion examples/pagination_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn main() {
spotify.prompt_for_user_token().unwrap();

// Typical iteration, no extra boilerplate needed.
let stream = spotify.current_user_saved_tracks_auto();
let stream = spotify.current_user_saved_tracks();
println!("Items:");
for item in stream {
println!("* {}", item.unwrap().track.name);
Expand Down
Loading