rspotify icon indicating copy to clipboard operation
rspotify copied to clipboard

convenience method to turn Page + Client into a Stream

Open blueforesticarus opened this issue 2 years ago • 3 comments

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 avatar May 25 '23 13:05 blueforesticarus

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.

blueforesticarus avatar May 26 '23 14:05 blueforesticarus

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

github-actions[bot] avatar Nov 23 '23 02:11 github-actions[bot]