[GH-ISSUE #415] convenience method to turn Page + Client into a Stream #137

Closed
opened 2026-02-27 20:23:20 +03:00 by kerem · 3 comments
Owner

Originally created by @blueforesticarus on GitHub (May 25, 2023).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/415

Is your feature request related to a problem? Please describe.
client methods like playlist return tracks (and maybe other things) as a Page. This page is currently not very useful, as any code using it should be written to deal with the case where are more pages, and (unless I missed it) there is no way in the library to get the next page. I also want to avoid refetching the first page of tracks (ie. by calling playlist_items).

Describe the solution you'd like
There should be a method

fn paginate<'a, T>(&'a self, mut page: Page<T>) -> Paginator<'_, ClientResult<T>> where
        T: Unpin + Send + Sync + DeserializeOwned + 'a;

Ie. one that does pagination over any Page. (For symmetry, perhaps a method on page as well, which takes a client.)

Additional context
I have a proof of concept I have pushed to my fork, see below.

Originally created by @blueforesticarus on GitHub (May 25, 2023). Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/415 **Is your feature request related to a problem? Please describe.** client methods like [playlist](https://docs.rs/rspotify/latest/rspotify/clients/trait.BaseClient.html#method.playlist) return [tracks](https://docs.rs/rspotify-model/0.11.7/rspotify_model/playlist/struct.FullPlaylist.html#structfield.tracks) (and maybe other things) as a `Page`. This page is currently not very useful, as any code using it should be written to deal with the case where are more pages, and (unless I missed it) there is no way in the library to get the next page. I also want to avoid refetching the first page of tracks (ie. by calling playlist_items). **Describe the solution you'd like** There should be a method ```rust fn paginate<'a, T>(&'a self, mut page: Page<T>) -> Paginator<'_, ClientResult<T>> where T: Unpin + Send + Sync + DeserializeOwned + 'a; ``` Ie. one that does pagination over any Page. (For symmetry, perhaps a method on page as well, which takes a client.) **Additional context** I have a proof of concept I have pushed to my fork, see below.
kerem 2026-02-27 20:23:20 +03:00
Author
Owner

@blueforesticarus commented on GitHub (May 26, 2023):

One design decision is whether to use the next url, or extracts the path from href and uses api_get (I currently do the former). The difference (which I can think of), would be if the user is somehow using the api behind a proxy and the urls in next still refer to "spotify.com". I do not know whether this happens or if using the api behind a proxy is even possible.

<!-- gh-comment-id:1564472987 --> @blueforesticarus commented on GitHub (May 26, 2023): One design decision is whether to use the next url, or extracts the path from href and uses `api_get` (I currently do the former). The difference (which I can think of), would be if the user is somehow using the api behind a proxy and the urls in `next` still refer to "spotify.com". I do not know whether this happens or if using the api behind a proxy is even possible.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 23, 2023):

Message to comment on stale issues. If none provided, will not mark issues stale

<!-- gh-comment-id:1823740590 --> @github-actions[bot] commented on GitHub (Nov 23, 2023): Message to comment on stale issues. If none provided, will not mark issues stale
Author
Owner

@github-actions[bot] commented on GitHub (Nov 28, 2025):

Message to comment on stale issues. If none provided, will not mark issues stale

<!-- gh-comment-id:3587752528 --> @github-actions[bot] commented on GitHub (Nov 28, 2025): Message to comment on stale issues. If none provided, will not mark issues stale
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#137
No description provided.