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

convenience method to turn Page + Client into a Stream #415

Open
blueforesticarus opened this issue May 25, 2023 · 2 comments
Open

convenience method to turn Page + Client into a Stream #415

blueforesticarus opened this issue May 25, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@blueforesticarus
Copy link

blueforesticarus commented May 25, 2023

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.

@blueforesticarus blueforesticarus added the enhancement New feature or request label May 25, 2023
blueforesticarus added a commit to segfault-s-pull-requests/rspotify that referenced this issue May 25, 2023
@blueforesticarus
Copy link
Author

blueforesticarus commented 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.

Copy link

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

@github-actions github-actions bot added the Stale label Nov 23, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2023
@ramsayleung ramsayleung removed the Stale label Dec 8, 2023
@ramsayleung ramsayleung reopened this Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants