[PR #178] [CLOSED] Make cache file a optional feature #292

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

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/178
Author: @ramsayleung
Created: 1/16/2021
Status: Closed

Base: masterHead: ramsay_cache_file_as_a_feature


📝 Commits (10+)

  • 2c8608c Make cache file a optional feature
  • 3426251 make cache file a feature
  • 6ea6b96 fix compile error
  • f8bfc3d Mark unnecessary functions to private.
  • f4326a7 fix clippy lint.
  • 45e1450 Fix compile error.
  • 6241976 Merge branch 'master' into ramsay_cache_file_as_a_feature
  • 47e0b56 Update CHANGELOG.
  • 02a368f Renam feature name from cache_file to cache-file
  • 57eb22e read_token_cache function enabled with cache-file feature.

📊 Changes

7 files changed (+76 additions, -48 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 Cargo.toml (+2 -1)
📝 examples/webapp/src/main.rs (+1 -2)
📝 examples/with_refresh_token.rs (+1 -1)
📝 src/client.rs (+3 -0)
📝 src/lib.rs (+2 -6)
📝 src/oauth2.rs (+64 -38)

📄 Description

Description

Trying to fix #135 #96, make cache file as a optional feature.

Motivation and Context

The cache file feature is useful, but the API surface is some kind of verbose, like do_something and do_something_without_cache. The developers have to explicitly choose cache function or without_cache function to control the way of how does the cache file work? It would be more ergonomic to make cache file as a feature to offer the right to developers to control how does it work ?

Dependencies

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

Please also list any relevant details for your test configuration

Test cache-file feature by hand:

  • request_client_token:
# Check if cache file is generated, expect to be nothing
cargo run --example track --no-default-feature --features="env-file cli client-reqwest request-default-tls" 

# Check if cache file is generated, expect that `.spotify_token_cache.json` is saved
cargo run --example track --no-default-feature --features="env-file cache-file cli client-reqwest request-default-tls"
  • request_user_token:
# Check if cache file is generated, expect to be nothing
cargo run --example me --features="env-file cli client-ureq ureq-rustls-tls" --no-default-features

# Check if cache file is generated, expect that `.spotify_token_cache.json` is saved
cargo run --example me --features="env-file cli client-ureq ureq-rustls-tls cache-file" --no-default-features

🔄 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/178 **Author:** [@ramsayleung](https://github.com/ramsayleung) **Created:** 1/16/2021 **Status:** ❌ Closed **Base:** `master` ← **Head:** `ramsay_cache_file_as_a_feature` --- ### 📝 Commits (10+) - [`2c8608c`](https://github.com/ramsayleung/rspotify/commit/2c8608c3399a8268a7831c2966ab2e9124f01d4a) Make cache file a optional feature - [`3426251`](https://github.com/ramsayleung/rspotify/commit/3426251bff6d441d0e6bb52e537578ffb6cb7963) make cache file a feature - [`6ea6b96`](https://github.com/ramsayleung/rspotify/commit/6ea6b96b45abe3675977d7c5e98d1fc2a0dd649a) fix compile error - [`f8bfc3d`](https://github.com/ramsayleung/rspotify/commit/f8bfc3d27734c4a29440977f52ecc960a17e6237) Mark unnecessary functions to private. - [`f4326a7`](https://github.com/ramsayleung/rspotify/commit/f4326a710dc860c86cbbccb3413e4a629a8ffae9) fix clippy lint. - [`45e1450`](https://github.com/ramsayleung/rspotify/commit/45e14503497272b782b2d0395d128d5b98f3c481) Fix compile error. - [`6241976`](https://github.com/ramsayleung/rspotify/commit/6241976e8a13b00692a92ba836e65128ffc59314) Merge branch 'master' into ramsay_cache_file_as_a_feature - [`47e0b56`](https://github.com/ramsayleung/rspotify/commit/47e0b56b0052fa7e4a6d99ab0650b6c6d4781716) Update CHANGELOG. - [`02a368f`](https://github.com/ramsayleung/rspotify/commit/02a368ffaf01b35a363e1ebf5efac5d1b9201896) Renam feature name from `cache_file` to `cache-file` - [`57eb22e`](https://github.com/ramsayleung/rspotify/commit/57eb22e2c92c9f5b6ffc9a1ab27eb6613b6c77f9) `read_token_cache` function enabled with `cache-file` feature. ### 📊 Changes **7 files changed** (+76 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `Cargo.toml` (+2 -1) 📝 `examples/webapp/src/main.rs` (+1 -2) 📝 `examples/with_refresh_token.rs` (+1 -1) 📝 `src/client.rs` (+3 -0) 📝 `src/lib.rs` (+2 -6) 📝 `src/oauth2.rs` (+64 -38) </details> ### 📄 Description ## Description Trying to fix #135 #96, make cache file as a optional feature. ## Motivation and Context The cache file feature is useful, but the API surface is some kind of verbose, like `do_something` and `do_something_without_cache`. The developers have to explicitly choose `cache` function or `without_cache` function to control the way of how does the cache file work? It would be more ergonomic to make cache file as a feature to offer the right to developers to control how does it work ? ## Dependencies ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] This change requires a documentation update ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration Test `cache-file` feature by hand: + `request_client_token`: ```rust # Check if cache file is generated, expect to be nothing cargo run --example track --no-default-feature --features="env-file cli client-reqwest request-default-tls" # Check if cache file is generated, expect that `.spotify_token_cache.json` is saved cargo run --example track --no-default-feature --features="env-file cache-file cli client-reqwest request-default-tls" ``` + `request_user_token`: ```rust # Check if cache file is generated, expect to be nothing cargo run --example me --features="env-file cli client-ureq ureq-rustls-tls" --no-default-features # Check if cache file is generated, expect that `.spotify_token_cache.json` is saved cargo run --example me --features="env-file cli client-ureq ureq-rustls-tls cache-file" --no-default-features ``` --- <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:07 +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#292
No description provided.