[PR #364] Added a builder like struct for the search function (Related with issue ) #415

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

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/364
Author: @GartoxFR
Created: 10/16/2022
Status: 🔄 Open

Base: masterHead: type-safe-search


📝 Commits (9)

  • 82878ed Added a builder like struct for the search function
  • 7995a07 New type safe system with traits
  • 320d0f5 Revert "New type safe system with traits"
  • 5b5e60d Fixed comments :
  • 87c9c2d SearchQuery :
  • 92ae1a4 Removed useless example
  • 6044d8f Fix english mistakes
  • 04e4f8a Changed "any" query to append when used multiple times
  • 3462c77 Fix missing import in doc

📊 Changes

5 files changed (+186 additions, -6 deletions)

View changed files

📝 rspotify-model/src/search.rs (+18 -0)
📝 src/clients/base.rs (+4 -3)
📝 src/lib.rs (+1 -0)
src/search/mod.rs (+152 -0)
📝 tests/test_with_oauth.rs (+11 -3)

📄 Description

Description

These changes add a struct to build well formatted query to pass to the search method (fixes #354).
These are not breaking changes as you can still pass a simple String to the method.
It can still be improve as it doesn't prevent users to pass wrong filter with wrong SearchType (give a track title to search an album for example, which is not supporte by Spotify API).

Motivation and Context

Make writing searches easier

Dependencies

Adding strum to the main project

Type of change

Please delete options that are not relevant.

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

How has this been tested?

I've modified one test case to use the struct instead of a basic &str. As the old test still passes, these changes are non breaking.

I also wrote a simple example which printed the String generated by the struct to verify that it was right with its inputs. This file is included in this PR but will probably be removed if it is accepted.

Please also list any relevant details for your test configuration

Is this change properly documented?

Please make sure you've properly documented the changes you're making.

Don't forget to add an entry to the CHANGELOG if necessary (new features, breaking changes, relevant internal improvements).


🔄 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/364 **Author:** [@GartoxFR](https://github.com/GartoxFR) **Created:** 10/16/2022 **Status:** 🔄 Open **Base:** `master` ← **Head:** `type-safe-search` --- ### 📝 Commits (9) - [`82878ed`](https://github.com/ramsayleung/rspotify/commit/82878edefae5fe97a2cd1774bce1eb2a9dd21969) Added a builder like struct for the search function - [`7995a07`](https://github.com/ramsayleung/rspotify/commit/7995a0774a7aca68dd01635173d52551cbb6a922) New type safe system with traits - [`320d0f5`](https://github.com/ramsayleung/rspotify/commit/320d0f5dd3ebd92e66c088a39fe5251acebfbf52) Revert "New type safe system with traits" - [`5b5e60d`](https://github.com/ramsayleung/rspotify/commit/5b5e60db5f213aea0539983b192c0f941aa3abf1) Fixed comments : - [`87c9c2d`](https://github.com/ramsayleung/rspotify/commit/87c9c2d1409af7ec081e43c8d087b7a7fc40d351) SearchQuery : - [`92ae1a4`](https://github.com/ramsayleung/rspotify/commit/92ae1a4c95b78862cbdbaf963689619f32544cea) Removed useless example - [`6044d8f`](https://github.com/ramsayleung/rspotify/commit/6044d8fdb3e6745df870f554e575ee9db9c7dfc4) Fix english mistakes - [`04e4f8a`](https://github.com/ramsayleung/rspotify/commit/04e4f8ae55d16e268b02355596bc93951b05c1bb) Changed "any" query to append when used multiple times - [`3462c77`](https://github.com/ramsayleung/rspotify/commit/3462c77e32b94b8df2f21d164b3f1c770536119a) Fix missing import in doc ### 📊 Changes **5 files changed** (+186 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `rspotify-model/src/search.rs` (+18 -0) 📝 `src/clients/base.rs` (+4 -3) 📝 `src/lib.rs` (+1 -0) ➕ `src/search/mod.rs` (+152 -0) 📝 `tests/test_with_oauth.rs` (+11 -3) </details> ### 📄 Description ## Description These changes add a struct to build well formatted query to pass to the search method (fixes #354). These are not breaking changes as you can still pass a simple String to the method. It can still be improve as it doesn't prevent users to pass wrong filter with wrong SearchType (give a track title to search an album for example, which is not supporte by Spotify API). ## Motivation and Context Make writing searches easier ## Dependencies Adding strum to the main project ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) - [X] This change requires a documentation update ## How has this been tested? I've modified one test case to use the struct instead of a basic &str. As the old test still passes, these changes are non breaking. I also wrote a simple example which printed the String generated by the struct to verify that it was right with its inputs. This file is included in this PR but will probably be removed if it is accepted. Please also list any relevant details for your test configuration ## Is this change properly documented? Please make sure you've properly documented the changes you're making. Don't forget to add an entry to the CHANGELOG if necessary (new features, breaking changes, relevant internal improvements). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#415
No description provided.