-
Notifications
You must be signed in to change notification settings - Fork 124
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
Polish Token and OAuth #185
Conversation
dd2331c
to
21a5e5e
Compare
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.
Great job! I've just included a few commits to have neater iterators for converting between HashSet and Vec, and a few other improvements, although if you consider any of them let me know and revert them.
…/rspotify into ramsay_optimize_expire_field
You do a great job to reduce unnecessary operation, it's no way to revert them :) PS: Perhaps you could take time to review this PR #184 if you are free, it fix some failed CI jobs, then we could merge master branch into current PR later to fix the failed CI. |
@marioortizmanero you could take time to review this PR again, I think the required commits are completed :) |
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.
Ok after these comments it should be good to go!
Another thing I would like to consider is whether we'd be better off using BTreeSet
instead of HashSet
or not. Here's a comparison I've read: https://stackoverflow.com/questions/62558996/what-is-the-time-complexity-of-iterating-btreeset-and-hashset. This is also interesting: https://doc.rust-lang.org/std/collections/index.html#when-should-you-use-which-collection
What we mainly need is:
- Iteration of the elements
- Inserting new elements
It does look like a HashSet
is the best way to go, but I just wanted to make sure.
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.
LGTM! Great work
Description
As @Kestrer pointed out in #127, the
expires_at
andexpires_in
are not that easy to use:There is no way to store expires information into a signle field, since the response of requesting to
Spotify
for an access token looks like this:It's possible to deserialize this
expires_in
toToken.expire
field, like this:In order to convert expires_in(
elapsed
) toInstant
, it's necessory to instantiate aInstant
object indeserialize
function, it turns out to be a stateful function. If we serialize theToken
into cache file and deserialize it toToken
, then theexpires
value will change unexpectedly.Hence, it's necessary to keep two fields(
expires_in
,expires_at
) to handle expire information, theexpires_in
has been updated fromu32
tostd::time::Duration
, and theexpires_at
field has been updated fromu64
tochrono::DateTime
.For more details about the support of
serde
forstd::time::Instant
, check this issue: serde-rs/serde#1375Motivation and Context
To make
rspotify
ergonomic to use. Modification:Token.expires_in
fromu32
tostd::time::Duration
Token.expires_at
fromi64
tochrono::DateTime<Utc>
Token.scope
fromString
toHashSet
.OAuth.scope
fromString
toHashSet
.Dependencies
None
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
test_write_token
test_token_is_expired