mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 16:05:53 +03:00
[PR #161] [MERGED] Initial id type proposal #279
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#279
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ramsayleung/rspotify/pull/161
Author: @kstep
Created: 11/29/2020
Status: ✅ Merged
Merged: 3/7/2021
Merged by: @marioortizmanero
Base:
master← Head:uri-type📝 Commits (10+)
fcd9aceinitial id type proposal58e4c19use strip_prefix() (clippy advice)c3e722eadd try_join() and map_try_join()24a61dcremove itertoolse79e9bbrewrite try joinf0d26bbcleanup8155bc4from for iderror158eb0bfix try_join/map_try_join59eab11remove map_try_joinc4d0ef8get show, shows, episodes methods use &str instead of String and validate id📊 Changes
14 files changed (+700 additions, -484 deletions)
View changed files
📝
CHANGELOG.md(+12 -3)📝
examples/album.rs(+2 -1)📝
examples/track.rs(+2 -1)📝
examples/tracks.rs(+3 -2)📝
examples/with_refresh_token.rs(+4 -3)📝
src/client.rs(+198 -334)📝
src/model/enums/types.rs(+2 -2)➕
src/model/idtypes.rs(+301 -0)📝
src/model/mod.rs(+60 -0)📝
src/model/offset.rs(+13 -22)📝
src/model/track.rs(+14 -2)📝
tests/test_models.rs(+0 -21)📝
tests/test_with_credential.rs(+26 -24)📝
tests/test_with_oauth.rs(+63 -69)📄 Description
Description
This is a refactoring/change proposal. Introduces several changes and refactorings to the API:
Idtype to represent Spotify id/URI,ClientErrorvariant:InvalidId(IdError),.get_id()and.get_uri()methods,itertools, used it in API methods,AsRefStrforType.The main point of the change is to introduce
Idtype. This type abstracts out the following Spotify id/URI operations:IdErrorerror if id/URI is invalid.This type replaces both
.get_id()and.get_uri()methods.Also,
Spotifymethods are changed to use this type instead of.get_id()and.get_uri().This type, being zero-copy, should also reduce the number of allocations.
This change is a proposal only!
Open Questions/TODO
IdandIdErrortypes, put them intomodel/mod.rsfor now.Idplacement, so I left them inmodel/mod.rsfor now.Cow<'_, str>andInto<Cow<'_, str>>types for internalIddata representation and method arguments.Motivation and Context
As per TODO comments in code, and as a part of the refactoring effort as per #127 and #160, I decided to propose a new type to abstract out Spotify id/URI operations. Overall improvements:
Type of change
How Has This Been Tested?
.get_id()/.get_uri()methods..env) withcargo testcommand.This change is
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.