mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[PR #129] [MERGED] Multiple clients via features #260
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#260
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/129
Author: @marioortizmanero
Created: 9/20/2020
Status: ✅ Merged
Merged: 10/18/2020
Merged by: @ramsayleung
Base:
master← Head:multiple-clients📝 Commits (10+)
e4f85f8First attempt with Derefd0e7a5fFormatting and Cargo.toml fix279c138Implemented run_blocking macro7532b3fFix tokio import for tests, small cleanupe783eaeImplemented macro for a single functiond3e821cNow with docs too9c783ddSingle impl block, documentation675aeb7More clear formatting578c13bApplied to all endpoints with a vim macro!2c29637Fixed docstrings📊 Changes
34 files changed (+3048 additions, -5183 deletions)
View changed files
📝
.github/workflows/ci.yml(+18 -4)📝
CHANGELOG.md(+27 -6)📝
Cargo.toml(+52 -31)📝
README.md(+24 -0)📝
examples/album.rs(+31 -12)➖
examples/blocking/device.rs(+0 -39)➖
examples/blocking/me.rs(+0 -39)➖
examples/blocking/search.rs(+0 -98)➖
examples/blocking/seek_track.rs(+0 -41)📝
examples/current_user_recently_played.rs(+40 -30)➕
examples/oauth_tokens.rs(+45 -0)📝
examples/track.rs(+31 -12)📝
examples/tracks.rs(+29 -12)➕
examples/ureq/device.rs(+48 -0)➕
examples/ureq/me.rs(+47 -0)➕
examples/ureq/search.rs(+108 -0)➕
examples/ureq/seek_track.rs(+49 -0)📝
examples/webapp/Cargo.toml(+1 -1)📝
examples/webapp/src/main.rs(+107 -80)📝
examples/with_refresh_token.rs(+49 -37)...and 14 more files
📄 Description
This is a second attempt for fixing #112. The original idea at #120 was to have a
blockingmodule that would call the async implementations with a blocking runtime in order to avoid code duplication. This turned up to be a bad idea, because it wasn't as easy and flexible as I thought. This new approach uses themaybe-asynccrate, which makes it relatively easy to use multiple HTTP clients in the same crate with features. Instead of having ablockingmodule, the user may configure what client is used like so:rspotify = { version = "...", default_features = false, features = "client-ureq" }(client-reqwestis still the default).Advantages of this approach:
ureqinstead ofreqwest, which is much more minimal.macro_rules!macro. These are quick and easy to implement, but supporting generic parameters and other compex stuff can get out of hands pretty quickly. This avoids any workarounds for that.derive_derefdependency isn't necessary.Disadvantages of this approach:
maybe-async. It's just a procedural macro so no performance impact whatsoever. This also requiresasync_trait.Required changes and progress
reqwestureqwebappexamplemaybe_asyncabout the parenthesis warnings when usingureq: https://github.com/fMeow/maybe-async-rs/issues/1Read the CHANGELOG.md additions for more changes (most of them are from #127). I had to rewrite the
fetch_access_tokenlogic so that it can use the HTTP client inSpotify, and I ended up improving lots of other stuff I saw. (this is still very WIP, along with the first two points of this section).I've left lots of
TODOs that can be discussed after this is merged. I'd like to finish this ASAP so that other changes can be made without merge conflicts and without having to apply them for the blocking module as well.Also see the examples, some of them have been modified to show how the API works now.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
is_playablealways beingNone#351