-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial id type proposal #161
Conversation
Is it a good idea to move |
IMO passing I would love to hear @ramsayleung's opinion about this. |
I can see that you're really avoiding allocations to progress towards #160. I wanted to disscuss about this before we make any changes because it's a somewhat complicated topic in Rust. I've been trying to learn about when to use
I personally think that these kind of optimizations can be a pain for both programmers and users, and most times they aren't even noticeable. Specially if we end up propagating the use of As far as I know, this library never intended to be a performant API wrapper for Spotify. In fact, we don't say anything about what the goals of Rspotify are in the README. Being the most popular wrapper in Rust for the Spotify API, my assumption would be that Rspotify aims to be the most flexible and feature-full one, which isn't fully compatible with being the most performant one. |
I see your point here. Actually, I gave |
I resolved the conflicts, cleaned and reformatted the code a little bit. Please feel free to check if it's OK now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beside the small nitpicks I commented, LGTM! What do you think, @ramsayleung?
Yep, it's same to me, beside the small nitpicks, it looks good to me now :) |
Tests started to fail on the authentication stage. I'm pretty sure, it's unrelated to my changes. It's either some transient error, or some auth token got invalid for some reason, or the API got changed in some way. |
I'm merging the PR then! Thanks a bunch for the changes and for your patience, @kstep, it's been a long time haha. If you want to change anything just make a new PR as this one is huge already. As to the Auth issue, I'll take a look later then. |
Cheers! |
Description
This is a refactoring/change proposal. Introduces several changes and refactorings to the API:
Id
type to represent Spotify id/URI,ClientError
variant:InvalidId(IdError)
,.get_id()
and.get_uri()
methods,itertools
, used it in API methods,AsRefStr
forType
.The main point of the change is to introduce
Id
type. This type abstracts out the following Spotify id/URI operations:IdError
error if id/URI is invalid.This type replaces both
.get_id()
and.get_uri()
methods.Also,
Spotify
methods 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
Id
andIdError
types, put them intomodel/mod.rs
for now.Id
placement, so I left them inmodel/mod.rs
for now.Cow<'_, str>
andInto<Cow<'_, str>>
types for internalId
data 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 test
command.This change is