[PR #166] [MERGED] [WIP/Proposal] Add Stream/Iterator based versions of methods with paginated results #280

Closed
opened 2026-02-27 20:24:05 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/166
Author: @icewind1991
Created: 12/16/2020
Status: Merged
Merged: 4/19/2021
Merged by: @ramsayleung

Base: masterHead: streaming


📝 Commits (10+)

  • de3ae9a add streaming version of current_user_saved_tracks
  • 107d442 add sync version of current_user_saved_tracks_stream
  • 15af71a futures-utils -> futures
  • 962915e remove dependency on itertools
  • ed81f59 make page size configurable for streaming methods
  • 7c670f5 use trait aliases to prevent having to write a duplicate implementation for the streaming methods
  • ec10ad2 Merge branch 'master' into streaming
  • 2f7d180 fix lints
  • beb2949 actually fixes clippy lint
  • ad31a00 Merge branch 'master' into streaming

📊 Changes

12 files changed (+470 additions, -19 deletions)

View changed files

📝 Cargo.toml (+19 -2)
📝 examples/oauth_tokens.rs (+5 -5)
examples/pagination_async.rs (+75 -0)
examples/pagination_manual.rs (+72 -0)
examples/pagination_sync.rs (+63 -0)
📝 examples/with_refresh_token.rs (+12 -12)
📝 src/client.rs (+13 -0)
📝 src/lib.rs (+3 -0)
src/pagination/iter.rs (+95 -0)
src/pagination/mod.rs (+13 -0)
src/pagination/stream.rs (+36 -0)
📝 tests/test_with_credential.rs (+64 -0)

📄 Description

Note, this currently only implements the streaming version for one method to avoid wasting work until we're certain of the design.

Description

Adds an alternative version of methods that return paginated results, providing instead an Iterator or Stream (for sync/async respectively)

Motivation and Context

Manually iterating over paginated results is pretty annoying to do, by providing an streaming alternative we can make this a lot easier for consumers of the api.

Dependencies

New dependencies:

  • for async:
    • async-stream for creating the stream from async method calls
    • futures provides the Stream trait

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Added examples using the new methods and running them


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ramsayleung/rspotify/pull/166 **Author:** [@icewind1991](https://github.com/icewind1991) **Created:** 12/16/2020 **Status:** ✅ Merged **Merged:** 4/19/2021 **Merged by:** [@ramsayleung](https://github.com/ramsayleung) **Base:** `master` ← **Head:** `streaming` --- ### 📝 Commits (10+) - [`de3ae9a`](https://github.com/ramsayleung/rspotify/commit/de3ae9acd8f03c87f5b29c31d142d16b79405170) add streaming version of `current_user_saved_tracks` - [`107d442`](https://github.com/ramsayleung/rspotify/commit/107d442473cef0e7d44cc7c96977b826190d6c26) add sync version of `current_user_saved_tracks_stream` - [`15af71a`](https://github.com/ramsayleung/rspotify/commit/15af71a6bb57a6ab012bbf98a5755cb1e11e01d3) futures-utils -> futures - [`962915e`](https://github.com/ramsayleung/rspotify/commit/962915e706adddb5774433ed3d17359e2ea551c8) remove dependency on itertools - [`ed81f59`](https://github.com/ramsayleung/rspotify/commit/ed81f59bc88b5419cb6c1742f3def28db402cf38) make page size configurable for streaming methods - [`7c670f5`](https://github.com/ramsayleung/rspotify/commit/7c670f5af080eb54b6fe4e2dd8844b737fcf0ae9) use trait aliases to prevent having to write a duplicate implementation for the streaming methods - [`ec10ad2`](https://github.com/ramsayleung/rspotify/commit/ec10ad20ff2695192cee095ec1f1014830eb881d) Merge branch 'master' into streaming - [`2f7d180`](https://github.com/ramsayleung/rspotify/commit/2f7d180f6a1079a89b8275d400a8e7f8a03f3d20) fix lints - [`beb2949`](https://github.com/ramsayleung/rspotify/commit/beb29494c5eabcaaefeb27d350afea016288d1b1) actually fixes clippy lint - [`ad31a00`](https://github.com/ramsayleung/rspotify/commit/ad31a006bf59b451f3b9725e5556a9146d69df51) Merge branch 'master' into streaming ### 📊 Changes **12 files changed** (+470 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.toml` (+19 -2) 📝 `examples/oauth_tokens.rs` (+5 -5) ➕ `examples/pagination_async.rs` (+75 -0) ➕ `examples/pagination_manual.rs` (+72 -0) ➕ `examples/pagination_sync.rs` (+63 -0) 📝 `examples/with_refresh_token.rs` (+12 -12) 📝 `src/client.rs` (+13 -0) 📝 `src/lib.rs` (+3 -0) ➕ `src/pagination/iter.rs` (+95 -0) ➕ `src/pagination/mod.rs` (+13 -0) ➕ `src/pagination/stream.rs` (+36 -0) 📝 `tests/test_with_credential.rs` (+64 -0) </details> ### 📄 Description Note, this currently only implements the streaming version for one method to avoid wasting work until we're certain of the design. ## Description Adds an alternative version of methods that return paginated results, providing instead an `Iterator` or `Stream` (for `sync`/`async` respectively) ## Motivation and Context Manually iterating over paginated results is pretty annoying to do, by providing an streaming alternative we can make this a lot easier for consumers of the api. ## Dependencies New dependencies: - for async: - [async-stream](https://crates.io/crates/async-stream) for creating the stream from async method calls - [futures](https://crates.io/crates/futures) provides the `Stream` trait ## Type of change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ## How Has This Been Tested? Added examples using the new methods and running them --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:24:05 +03:00
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#280
No description provided.