Skip to content
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

Fix feature conflicts v2 #253

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ jobs:
RUST_BACKTRACE: 1
strategy:
matrix:
features:
- rspotify/cli,rspotify/env-file,rspotify/client-ureq,rspotify/ureq-rustls-tls,rspotify-http/client-ureq,rspotify-http/ureq-rustls-tls
- rspotify/cli,rspotify/env-file,rspotify/client-reqwest,rspotify/reqwest-rustls-tls,rspotify-http/client-reqwest,rspotify-http/reqwest-rustls-tls
# For testing both async and sync
directory:
- .
- rspotify-sync
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Change directory
run: cd ${{ matrix.directory }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -82,10 +86,10 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: -p rspotify -p rspotify-http -p rspotify-model -p rspotify-macros --no-default-features --features=${{ matrix.features }} -- -D warnings
args: --workspace --all-features -- -D warnings

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: -p rspotify -p rspotify-http -p rspotify-model -p rspotify-macros --no-default-features --features=${{ matrix.features }}
args: --workspace --all-features
82 changes: 28 additions & 54 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ authors = [
"Ramsay Leung <[email protected]>",
"Mario Ortiz Manero <[email protected]>"
]
name = "rspotify"
name = "rspotify-async"
version = "0.10.0"
license = "MIT"
readme = "README.md"
description = "Spotify API wrapper"
description = "Asynchronous Spotify API wrapper"
homepage = "https://github.com/ramsayleung/rspotify"
repository = "https://github.com/ramsayleung/rspotify"
keywords = ["spotify", "api"]
Expand All @@ -17,9 +17,12 @@ edition = "2018"
members = [
"rspotify-macros",
"rspotify-model",
"rspotify-http"
]
exclude = [
# The synchronous crate must not be in the same workspace so that commands
# like `--workspace` don't enable both async and sync and thus fail due to
# conflicts.
"rspotify-sync",
"examples/webapp"
]
# For advanced features usage in the CLI, see:
Expand All @@ -29,23 +32,25 @@ resolver = "2"
[dependencies]
rspotify-macros = { path = "rspotify-macros", version = "0.10.0" }
rspotify-model = { path = "rspotify-model", version = "0.10.0" }
rspotify-http = { path = "rspotify-http", version = "0.10.0", default-features = false }

async-stream = { version = "0.3.2", optional = true }
async-trait = { version = "0.1.51", optional = true }
async-stream = "0.3.2"
async-trait = "0.1.51"
base64 = "0.13.0"
chrono = { version = "0.4.19", features = ["serde", "rustc-serialize"] }
dotenv = { version = "0.15.0", optional = true }
futures = { version = "0.3.17", optional = true }
futures = "0.3.17"
getrandom = "0.2.3"
log = "0.4.14"
maybe-async = "0.2.6"
serde = { version = "1.0.130", default-features = false }
serde_json = "1.0.67"
serde_json = "1.0.68"
thiserror = "1.0.29"
url = "2.2.2"
webbrowser = { version = "0.5.5", optional = true }

# Supported clients
reqwest = { version = "0.11.4", default-features = false, features = ["json", "socks"], optional = true }

[dev-dependencies]
env_logger = { version = "0.9.0", default-features = false }
tokio = { version = "1.11.0", features = ["rt-multi-thread", "macros"] }
Expand All @@ -59,83 +64,52 @@ cli = ["webbrowser"]
env-file = ["dotenv"]

### HTTP ###
# Available clients. By default they don't include a TLS so that it can be
# configured.
client-ureq = ["rspotify-http/client-ureq", "__sync"]
client-reqwest = ["rspotify-http/client-reqwest", "__async"]
# Only asynchronous clients are listed here.
client-reqwest = ["reqwest", "__async"]

# Passing the TLS features to reqwest.
reqwest-default-tls = ["rspotify-http/reqwest-default-tls"]
reqwest-rustls-tls = ["rspotify-http/reqwest-rustls-tls"]
reqwest-native-tls = ["rspotify-http/reqwest-native-tls"]
reqwest-native-tls-vendored = ["rspotify-http/reqwest-native-tls-vendored"]
# Same for ureq.
ureq-rustls-tls = ["rspotify-http/ureq-rustls-tls"]
reqwest-default-tls = ["reqwest/default-tls"]
reqwest-rustls-tls = ["reqwest/rustls-tls"]
reqwest-native-tls = ["reqwest/native-tls"]
reqwest-native-tls-vendored = ["reqwest/native-tls-vendored"]

# Internal features for checking async or sync compilation
__async = ["futures", "async-stream", "async-trait"]
__sync = ["maybe-async/is_sync"]
__async = []

[package.metadata.docs.rs]
# Documenting the CLI methods, and working links for `dotenv`
features = ["cli", "env-file"]
all-features = true

[[example]]
name = "client_creds"
required-features = ["env-file", "cli", "client-reqwest"]
required-features = ["env-file", "cli"]
path = "examples/client_creds.rs"

[[example]]
name = "auth_code"
required-features = ["env-file", "cli", "client-reqwest"]
required-features = ["env-file", "cli"]
path = "examples/auth_code.rs"

[[example]]
name = "auth_code_pkce"
required-features = ["env-file", "cli", "client-reqwest"]
required-features = ["env-file", "cli"]
path = "examples/auth_code_pkce.rs"

[[example]]
name = "oauth_tokens"
required-features = ["env-file", "cli", "client-reqwest"]
required-features = ["env-file", "cli"]
path = "examples/oauth_tokens.rs"

[[example]]
name = "with_refresh_token"
required-features = ["env-file", "cli", "client-reqwest"]
required-features = ["env-file", "cli"]
path = "examples/with_refresh_token.rs"

[[example]]
name = "device"
required-features = ["env-file", "cli", "client-ureq"]
path = "examples/ureq/device.rs"

[[example]]
name = "me"
required-features = ["env-file", "cli", "client-ureq"]
path = "examples/ureq/me.rs"

[[example]]
name = "search"
required-features = ["env-file", "cli", "client-ureq"]
path = "examples/ureq/search.rs"

[[example]]
name = "seek_track"
required-features = ["env-file", "cli", "client-ureq"]
path = "examples/ureq/seek_track.rs"

[[example]]
name = "pagination_manual"
required-features = ["env-file", "cli", "client-reqwest"]
required-features = ["env-file", "cli"]
path = "examples/pagination_manual.rs"

[[example]]
name = "pagination_sync"
required-features = ["env-file", "cli", "client-ureq"]
path = "examples/pagination_sync.rs"

[[example]]
name = "pagination_async"
required-features = ["env-file", "cli", "client-reqwest"]
required-features = ["env-file", "cli"]
path = "examples/pagination_async.rs"
5 changes: 3 additions & 2 deletions examples/auth_code.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rspotify::{
use rspotify_async::{
http::ReqwestClient,
model::{AdditionalType, Country, Market},
prelude::*,
scopes, AuthCodeSpotify, Credentials, OAuth,
Expand Down Expand Up @@ -38,7 +39,7 @@ async fn main() {
// ```
let oauth = OAuth::from_env(scopes!("user-read-currently-playing")).unwrap();

let mut spotify = AuthCodeSpotify::new(creds, oauth);
let mut spotify = AuthCodeSpotify::<ReqwestClient>::new(creds, oauth);

// Obtaining the access token
let url = spotify.get_authorize_url(false).unwrap();
Expand Down
6 changes: 4 additions & 2 deletions examples/auth_code_pkce.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use rspotify::{prelude::*, scopes, AuthCodePkceSpotify, Credentials, OAuth};
use rspotify_async::{
http::ReqwestClient, prelude::*, scopes, AuthCodePkceSpotify, Credentials, OAuth,
};

#[tokio::main]
async fn main() {
Expand Down Expand Up @@ -34,7 +36,7 @@ async fn main() {
// ```
let oauth = OAuth::from_env(scopes!("user-read-recently-played")).unwrap();

let mut spotify = AuthCodePkceSpotify::new(creds, oauth);
let mut spotify = AuthCodePkceSpotify::<ReqwestClient>::new(creds, oauth);

// Obtaining the access token
let url = spotify.get_authorize_url().unwrap();
Expand Down
6 changes: 4 additions & 2 deletions examples/client_creds.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use rspotify::{model::AlbumId, prelude::*, ClientCredsSpotify, Credentials};
use rspotify_async::{
http::ReqwestClient, model::AlbumId, prelude::*, ClientCredsSpotify, Credentials,
};

#[tokio::main]
async fn main() {
Expand All @@ -23,7 +25,7 @@ async fn main() {
// ```
let creds = Credentials::from_env().unwrap();

let mut spotify = ClientCredsSpotify::new(creds);
let mut spotify = ClientCredsSpotify::<ReqwestClient>::new(creds);

// Obtaining the access token. Requires to be mutable because the internal
// token will be modified. We don't need OAuth for this specific endpoint,
Expand Down
6 changes: 4 additions & 2 deletions examples/oauth_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
//! an .env file or export them manually as environmental variables for this to
//! work.

use rspotify::{prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth};
use rspotify_async::{
http::ReqwestClient, prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth,
};

#[tokio::main]
async fn main() {
Expand Down Expand Up @@ -38,7 +40,7 @@ async fn main() {
);
let oauth = OAuth::from_env(scopes).unwrap();

let mut spotify = AuthCodeSpotify::new(creds, oauth);
let mut spotify = AuthCodeSpotify::<ReqwestClient>::new(creds, oauth);

let url = spotify.get_authorize_url(false).unwrap();
spotify.prompt_for_token(&url).await.unwrap();
Expand Down
6 changes: 4 additions & 2 deletions examples/pagination_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

use futures::stream::TryStreamExt;
use futures_util::pin_mut;
use rspotify::{prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth};
use rspotify_async::{
http::ReqwestClient, prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth,
};

#[tokio::main]
async fn main() {
Expand All @@ -18,7 +20,7 @@ async fn main() {
let creds = Credentials::from_env().unwrap();
let oauth = OAuth::from_env(scopes!("user-library-read")).unwrap();

let mut spotify = AuthCodeSpotify::new(creds, oauth);
let mut spotify = AuthCodeSpotify::<ReqwestClient>::new(creds, oauth);

// Obtaining the access token
let url = spotify.get_authorize_url(false).unwrap();
Expand Down
6 changes: 4 additions & 2 deletions examples/pagination_manual.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! This example shows how manual pagination works. It's what the raw API
//! returns, but harder to use than an iterator or stream.

use rspotify::{prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth};
use rspotify_async::{
http::ReqwestClient, prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth,
};

#[tokio::main]
async fn main() {
Expand All @@ -11,7 +13,7 @@ async fn main() {
let creds = Credentials::from_env().unwrap();
let oauth = OAuth::from_env(scopes!("user-library-read")).unwrap();

let mut spotify = AuthCodeSpotify::new(creds, oauth);
let mut spotify = AuthCodeSpotify::<ReqwestClient>::new(creds, oauth);

// Obtaining the access token
let url = spotify.get_authorize_url(false).unwrap();
Expand Down
8 changes: 5 additions & 3 deletions examples/with_refresh_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
//! tokens](https://github.com/felix-hilden/tekore/issues/86), so in the case of
//! Spotify it doesn't seem to revoke them at all.

use rspotify::{model::ArtistId, prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth};
use rspotify_async::{
http::ReqwestClient, model::ArtistId, prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth,
};

// Sample request that will follow some artists, print the user's
// followed artists, and then unfollow the artists.
async fn do_things(spotify: AuthCodeSpotify) {
async fn do_things(spotify: AuthCodeSpotify<ReqwestClient>) {
let artists = [
&ArtistId::from_id("3RGLhK1IP9jnYFH4BRFJBS").unwrap(), // The Clash
&ArtistId::from_id("0yNLKJebCb8Aueb54LYya3").unwrap(), // New Order
Expand Down Expand Up @@ -56,7 +58,7 @@ async fn main() {
// The default credentials from the `.env` file will be used by default.
let creds = Credentials::from_env().unwrap();
let oauth = OAuth::from_env(scopes!("user-follow-read user-follow-modify")).unwrap();
let mut spotify = AuthCodeSpotify::new(creds.clone(), oauth.clone());
let mut spotify = AuthCodeSpotify::<ReqwestClient>::new(creds.clone(), oauth.clone());

// In the first session of the application we authenticate and obtain the
// refresh token. We can also do some requests here.
Expand Down
49 changes: 0 additions & 49 deletions rspotify-http/Cargo.toml

This file was deleted.

Loading