summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2021-02-19 00:31:05 +0000
committerDennis Kobert <dennis@kobert.dev>2021-02-19 00:31:05 +0000
commit5ae2fdf0e941b3ce13ad35363398782381179dad (patch)
treec0812c4204f31769bfa3bd571dde6ebe5ff348ad
parent90a4cfacbb64750a6779995e91509588f78e9802 (diff)
Update crates tu use async all the way
-rw-r--r--Cargo.lock1128
-rw-r--r--Cargo.toml8
-rw-r--r--Session.vim56
-rw-r--r--dist/callback.html20
-rw-r--r--src/database.rs164
-rw-r--r--src/errors.rs20
-rw-r--r--src/main.rs47
-rw-r--r--src/serve.rs16
-rw-r--r--src/spotify.rs95
9 files changed, 524 insertions, 1030 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4582ebd..47be2be 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,38 +1,14 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
-name = "addr2line"
-version = "0.14.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7"
-dependencies = [
- "gimli",
-]
-
-[[package]]
-name = "adler"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
-
-[[package]]
-name = "aho-corasick"
-version = "0.7.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
-dependencies = [
- "memchr",
-]
-
-[[package]]
name = "async-trait"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -41,7 +17,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281"
dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
]
[[package]]
@@ -52,36 +28,16 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
name = "autocfg"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
-
-[[package]]
-name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
-name = "backtrace"
-version = "0.3.56"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc"
-dependencies = [
- "addr2line",
- "cfg-if 1.0.0",
- "libc",
- "miniz_oxide",
- "object",
- "rustc-demangle",
-]
-
-[[package]]
name = "base-x"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -89,15 +45,6 @@ checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
[[package]]
name = "base64"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
-dependencies = [
- "byteorder",
-]
-
-[[package]]
-name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
@@ -137,22 +84,6 @@ checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
[[package]]
name = "bytes"
-version = "0.4.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
-dependencies = [
- "byteorder",
- "iovec",
-]
-
-[[package]]
-name = "bytes"
-version = "0.5.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
-
-[[package]]
-name = "bytes"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
@@ -165,12 +96,6 @@ checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48"
[[package]]
name = "cfg-if"
-version = "0.1.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
-
-[[package]]
-name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
@@ -187,16 +112,7 @@ dependencies = [
"rustc-serialize",
"serde",
"time 0.1.43",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "cloudabi"
-version = "0.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
-dependencies = [
- "bitflags",
+ "winapi",
]
[[package]]
@@ -210,7 +126,7 @@ name = "cookie"
version = "0.15.0-dev"
source = "git+https://github.com/SergioBenitez/cookie-rs.git?rev=1c3ca83#1c3ca838543b60a4448d279dc4b903cc7a2bc22a"
dependencies = [
- "percent-encoding 2.1.0",
+ "percent-encoding",
"time 0.2.25",
"version_check",
]
@@ -239,9 +155,9 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
[[package]]
name = "crypto-mac"
-version = "0.9.1"
+version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58bcd97a54c7ca5ce2f6eb16f6bede5b0ab5f0055fedc17d2f0b4466e21671ca"
+checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6"
dependencies = [
"generic-array",
"subtle",
@@ -249,9 +165,9 @@ dependencies = [
[[package]]
name = "darling"
-version = "0.9.0"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fcfbcb0c5961907597a7d1148e3af036268f2b773886b8bb3eeb1e1281d3d3d6"
+checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858"
dependencies = [
"darling_core",
"darling_macro",
@@ -259,52 +175,52 @@ dependencies = [
[[package]]
name = "darling_core"
-version = "0.9.0"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6afc018370c3bff3eb51f89256a6bdb18b4fdcda72d577982a14954a7a0b402c"
+checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b"
dependencies = [
"fnv",
"ident_case",
- "proc-macro2 0.4.30",
- "quote 0.6.13",
+ "proc-macro2",
+ "quote",
"strsim",
- "syn 0.15.44",
+ "syn",
]
[[package]]
name = "darling_macro"
-version = "0.9.0"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6d8dac1c6f1d29a41c4712b4400f878cb4fcc4c7628f298dd75038e024998d1"
+checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core",
- "quote 0.6.13",
- "syn 0.15.44",
+ "quote",
+ "syn",
]
[[package]]
name = "derive_builder"
-version = "0.7.2"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ac53fa6a3cda160df823a9346442525dcaf1e171999a1cf23e67067e4fd64d4"
+checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0"
dependencies = [
"darling",
"derive_builder_core",
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "syn 0.15.44",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
name = "derive_builder_core"
-version = "0.5.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0288a23da9333c246bb18c143426074a6ae96747995c5819d2947b64cd942b37"
+checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef"
dependencies = [
"darling",
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "syn 0.15.44",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -322,7 +238,7 @@ version = "0.3.0"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047"
dependencies = [
"devise_core",
- "quote 1.0.9",
+ "quote",
]
[[package]]
@@ -331,10 +247,10 @@ version = "0.3.0"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047"
dependencies = [
"bitflags",
- "proc-macro2 1.0.24",
+ "proc-macro2",
"proc-macro2-diagnostics",
- "quote 1.0.9",
- "syn 1.0.60",
+ "quote",
+ "syn",
]
[[package]]
@@ -354,14 +270,9 @@ checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
[[package]]
name = "dotenv"
-version = "0.13.0"
+version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d0a1279c96732bc6800ce6337b6a614697b0e74ae058dc03c62ebeb78b4d86"
-dependencies = [
- "failure",
- "lazy_static",
- "regex",
-]
+checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "either"
@@ -375,42 +286,7 @@ version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065"
dependencies = [
- "cfg-if 1.0.0",
-]
-
-[[package]]
-name = "env_logger"
-version = "0.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
-dependencies = [
- "atty",
- "humantime",
- "log",
- "regex",
- "termcolor",
-]
-
-[[package]]
-name = "failure"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
-dependencies = [
- "backtrace",
- "failure_derive",
-]
-
-[[package]]
-name = "failure_derive"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
-dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
- "synstructure",
+ "cfg-if",
]
[[package]]
@@ -461,32 +337,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00"
dependencies = [
"matches",
- "percent-encoding 2.1.0",
+ "percent-encoding",
]
[[package]]
-name = "fuchsia-cprng"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
-
-[[package]]
-name = "fuchsia-zircon"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
-dependencies = [
- "bitflags",
- "fuchsia-zircon-sys",
-]
-
-[[package]]
-name = "fuchsia-zircon-sys"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
-
-[[package]]
name = "futures"
version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -541,9 +395,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd"
dependencies = [
"proc-macro-hack",
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -574,7 +428,7 @@ dependencies = [
"futures-sink",
"futures-task",
"memchr",
- "pin-project-lite 0.2.4",
+ "pin-project-lite",
"pin-utils",
"proc-macro-hack",
"proc-macro-nested",
@@ -597,7 +451,7 @@ version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
@@ -608,18 +462,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
]
[[package]]
-name = "gimli"
-version = "0.23.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
-
-[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -627,31 +475,11 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "h2"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535"
-dependencies = [
- "bytes 0.5.6",
- "fnv",
- "futures-core",
- "futures-sink",
- "futures-util",
- "http",
- "indexmap",
- "slab",
- "tokio 0.2.25",
- "tokio-util 0.3.1",
- "tracing",
- "tracing-futures",
-]
-
-[[package]]
-name = "h2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5"
dependencies = [
- "bytes 1.0.1",
+ "bytes",
"fnv",
"futures-core",
"futures-sink",
@@ -659,8 +487,8 @@ dependencies = [
"http",
"indexmap",
"slab",
- "tokio 1.2.0",
- "tokio-util 0.6.3",
+ "tokio",
+ "tokio-util",
"tracing",
"tracing-futures",
]
@@ -672,6 +500,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]]
+name = "heck"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
name = "hermit-abi"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -682,9 +519,9 @@ dependencies = [
[[package]]
name = "hmac"
-version = "0.9.0"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "deae6d9dbb35ec2c502d62b8f7b1c000a0822c3b0794ba36b3149c0a1c840dff"
+checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15"
dependencies = [
"crypto-mac",
"digest",
@@ -696,28 +533,18 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747"
dependencies = [
- "bytes 1.0.1",
+ "bytes",
"fnv",
"itoa",
]
[[package]]
name = "http-body"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b"
-dependencies = [
- "bytes 0.5.6",
- "http",
-]
-
-[[package]]
-name = "http-body"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994"
dependencies = [
- "bytes 1.0.1",
+ "bytes",
"http",
]
@@ -734,57 +561,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
[[package]]
-name = "humantime"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
-dependencies = [
- "quick-error",
-]
-
-[[package]]
-name = "hyper"
-version = "0.13.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb"
-dependencies = [
- "bytes 0.5.6",
- "futures-channel",
- "futures-core",
- "futures-util",
- "h2 0.2.7",
- "http",
- "http-body 0.3.1",
- "httparse",
- "httpdate",
- "itoa",
- "pin-project",
- "socket2",
- "tokio 0.2.25",
- "tower-service",
- "tracing",
- "want",
-]
-
-[[package]]
name = "hyper"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8e946c2b1349055e0b72ae281b238baf1a3ea7307c7e9f9d64673bdd9c26ac7"
dependencies = [
- "bytes 1.0.1",
+ "bytes",
"futures-channel",
"futures-core",
"futures-util",
- "h2 0.3.0",
+ "h2",
"http",
- "http-body 0.4.0",
+ "http-body",
"httparse",
"httpdate",
"itoa",
"pin-project",
"socket2",
- "tokio 1.2.0",
+ "tokio",
"tower-service",
"tracing",
"want",
@@ -792,15 +586,15 @@ dependencies = [
[[package]]
name = "hyper-tls"
-version = "0.4.3"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed"
+checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
- "bytes 0.5.6",
- "hyper 0.13.10",
+ "bytes",
+ "hyper",
"native-tls",
- "tokio 0.2.25",
- "tokio-tls",
+ "tokio",
+ "tokio-native-tls",
]
[[package]]
@@ -811,17 +605,6 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
-dependencies = [
- "matches",
- "unicode-bidi",
- "unicode-normalization",
-]
-
-[[package]]
-name = "idna"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de910d521f7cc3135c4de8db1cb910e0b5ed1dc6f57c381cd07e8e661ce10094"
@@ -837,7 +620,7 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
"hashbrown",
]
@@ -853,16 +636,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
dependencies = [
- "cfg-if 1.0.0",
-]
-
-[[package]]
-name = "iovec"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
-dependencies = [
- "libc",
+ "cfg-if",
]
[[package]]
@@ -872,15 +646,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135"
[[package]]
-name = "itertools"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
-dependencies = [
- "either",
-]
-
-[[package]]
name = "itoa"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -896,16 +661,6 @@ dependencies = [
]
[[package]]
-name = "kernel32-sys"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-dependencies = [
- "winapi 0.2.8",
- "winapi-build",
-]
-
-[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -932,7 +687,7 @@ version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
]
[[package]]
@@ -942,6 +697,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
[[package]]
+name = "maybe-async"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd1afac51d14f8056cd544c83239b961c464e0a98c2ca65353195df93e636a20"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "md5"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -960,78 +726,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
-name = "mime_guess"
-version = "2.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
-dependencies = [
- "mime",
- "unicase",
-]
-
-[[package]]
-name = "miniz_oxide"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d"
-dependencies = [
- "adler",
- "autocfg 1.0.1",
-]
-
-[[package]]
name = "mio"
-version = "0.6.23"
+version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
+checksum = "dc250d6848c90d719ea2ce34546fb5df7af1d3fd189d10bf7bad80bfcebecd95"
dependencies = [
- "cfg-if 0.1.10",
- "fuchsia-zircon",
- "fuchsia-zircon-sys",
- "iovec",
- "kernel32-sys",
"libc",
"log",
- "miow 0.2.2",
- "net2",
- "slab",
- "winapi 0.2.8",
-]
-
-[[package]]
-name = "mio"
-version = "0.7.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7"
-dependencies = [
- "libc",
- "log",
- "miow 0.3.6",
+ "miow",
"ntapi",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "mio-uds"
-version = "0.6.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
-dependencies = [
- "iovec",
- "libc",
- "mio 0.6.23",
-]
-
-[[package]]
-name = "miow"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
-dependencies = [
- "kernel32-sys",
- "net2",
- "winapi 0.2.8",
- "ws2_32-sys",
+ "winapi",
]
[[package]]
@@ -1041,7 +745,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
dependencies = [
"socket2",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1063,23 +767,12 @@ dependencies = [
]
[[package]]
-name = "net2"
-version = "0.2.37"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
-dependencies = [
- "cfg-if 0.1.10",
- "libc",
- "winapi 0.3.9",
-]
-
-[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1088,7 +781,7 @@ version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
"num-traits",
]
@@ -1098,7 +791,7 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
]
[[package]]
@@ -1112,12 +805,6 @@ dependencies = [
]
[[package]]
-name = "object"
-version = "0.23.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4"
-
-[[package]]
name = "once_cell"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1136,7 +823,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70"
dependencies = [
"bitflags",
- "cfg-if 1.0.0",
+ "cfg-if",
"foreign-types",
"lazy_static",
"libc",
@@ -1155,7 +842,7 @@ version = "0.9.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6"
dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
"cc",
"libc",
"pkg-config",
@@ -1179,12 +866,12 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"instant",
"libc",
"redox_syscall",
"smallvec",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1204,20 +891,14 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "602cf1780ee9bbca663ea75769e05643e16fe87d7c8ac9f4f385a2ed8940a75c"
dependencies = [
- "proc-macro2 1.0.24",
+ "proc-macro2",
"proc-macro2-diagnostics",
- "quote 1.0.9",
- "syn 1.0.60",
+ "quote",
+ "syn",
]
[[package]]
name = "percent-encoding"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
-
-[[package]]
-name = "percent-encoding"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
@@ -1255,19 +936,13 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
name = "pin-project-lite"
-version = "0.1.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b"
-
-[[package]]
-name = "pin-project-lite"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
@@ -1285,44 +960,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
-name = "postgres"
-version = "0.17.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14d864cf6c2eabf1323afe4145ff273aad1898e4f2a3bcb30347715df8624a07"
-dependencies = [
- "bytes 0.5.6",
- "fallible-iterator",
- "futures",
- "log",
- "tokio 0.2.25",
- "tokio-postgres",
-]
-
-[[package]]
name = "postgres-protocol"
-version = "0.5.3"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4888a0e36637ab38d76cace88c1476937d617ad015f07f6b669cec11beacc019"
+checksum = "70e34ad3dc5c56d036b9418185ee97e14b6766d55c8ccf9dc18302ad4e6371d9"
dependencies = [
- "base64 0.13.0",
+ "base64",
"byteorder",
- "bytes 0.5.6",
+ "bytes",
"fallible-iterator",
"hmac",
"md5",
"memchr",
- "rand 0.7.3",
+ "rand 0.8.3",
"sha2",
"stringprep",
]
[[package]]
name = "postgres-types"
-version = "0.1.3"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cfc08a7d94a80665de4a83942fa8db2fdeaf2f123fc0535e384dc4fff251efae"
+checksum = "5493d9d4613b88b12433aa12890e74e74cd93fdc1e08b7c2aed4768aaae8414c"
dependencies = [
- "bytes 0.5.6",
+ "bytes",
"fallible-iterator",
"postgres-protocol",
]
@@ -1347,20 +1008,11 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]]
name = "proc-macro2"
-version = "0.4.30"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
-dependencies = [
- "unicode-xid 0.1.0",
-]
-
-[[package]]
-name = "proc-macro2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
- "unicode-xid 0.2.1",
+ "unicode-xid",
]
[[package]]
@@ -1369,54 +1021,20 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
"version_check",
"yansi",
]
[[package]]
-name = "quick-error"
-version = "1.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
-
-[[package]]
-name = "quote"
-version = "0.6.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
-dependencies = [
- "proc-macro2 0.4.30",
-]
-
-[[package]]
name = "quote"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [
- "proc-macro2 1.0.24",
-]
-
-[[package]]
-name = "rand"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
-dependencies = [
- "autocfg 0.1.7",
- "libc",
- "rand_chacha 0.1.1",
- "rand_core 0.4.2",
- "rand_hc 0.1.0",
- "rand_isaac",
- "rand_jitter",
- "rand_os",
- "rand_pcg",
- "rand_xorshift",
- "winapi 0.3.9",
+ "proc-macro2",
]
[[package]]
@@ -1446,16 +1064,6 @@ dependencies = [
[[package]]
name = "rand_chacha"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
-dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
@@ -1476,21 +1084,6 @@ dependencies = [
[[package]]
name = "rand_core"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
-dependencies = [
- "rand_core 0.4.2",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
-
-[[package]]
-name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
@@ -1509,15 +1102,6 @@ dependencies = [
[[package]]
name = "rand_hc"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
@@ -1535,74 +1119,6 @@ dependencies = [
]
[[package]]
-name = "rand_isaac"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_jitter"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
-dependencies = [
- "libc",
- "rand_core 0.4.2",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "rand_os"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
-dependencies = [
- "cloudabi",
- "fuchsia-cprng",
- "libc",
- "rand_core 0.4.2",
- "rdrand",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "rand_pcg"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
-dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.4.2",
-]
-
-[[package]]
-name = "rand_xorshift"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "random"
-version = "0.12.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "97d13a3485349981c90c79112a11222c3e6e75de1d52b87a7525b3bf5361420f"
-
-[[package]]
-name = "rdrand"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
name = "redox_syscall"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1626,69 +1142,50 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
-]
-
-[[package]]
-name = "regex"
-version = "1.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
-dependencies = [
- "aho-corasick",
- "memchr",
- "regex-syntax",
- "thread_local",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
-name = "regex-syntax"
-version = "0.6.22"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
-
-[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
name = "reqwest"
-version = "0.10.10"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c"
+checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de"
dependencies = [
- "base64 0.13.0",
- "bytes 0.5.6",
+ "base64",
+ "bytes",
"encoding_rs",
"futures-core",
"futures-util",
"http",
- "http-body 0.3.1",
- "hyper 0.13.10",
+ "http-body",
+ "hyper",
"hyper-tls",
"ipnet",
"js-sys",
"lazy_static",
"log",
"mime",
- "mime_guess",
"native-tls",
- "percent-encoding 2.1.0",
- "pin-project-lite 0.2.4",
+ "percent-encoding",
+ "pin-project-lite",
"serde",
"serde_json",
"serde_urlencoded",
- "tokio 0.2.25",
+ "tokio",
+ "tokio-native-tls",
"tokio-socks",
- "tokio-tls",
- "url 2.2.0",
+ "url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -1718,7 +1215,7 @@ dependencies = [
"serde",
"state",
"time 0.2.25",
- "tokio 1.2.0",
+ "tokio",
"ubyte",
"version_check",
"yansi",
@@ -1732,7 +1229,7 @@ dependencies = [
"devise",
"glob",
"indexmap",
- "quote 1.0.9",
+ "quote",
"rocket_http",
]
@@ -1745,7 +1242,7 @@ dependencies = [
"rocket",
"serde",
"serde_json",
- "tokio 1.2.0",
+ "tokio",
]
[[package]]
@@ -1756,57 +1253,46 @@ dependencies = [
"cookie",
"either",
"http",
- "hyper 0.14.4",
+ "hyper",
"indexmap",
"log",
"mime",
"parking_lot",
"pear",
- "percent-encoding 2.1.0",
- "pin-project-lite 0.2.4",
+ "percent-encoding",
+ "pin-project-lite",
"ref-cast",
"smallvec",
"state",
"time 0.2.25",
- "tokio 1.2.0",
+ "tokio",
"uncased",
- "unicode-xid 0.2.1",
+ "unicode-xid",
"version_check",
]
[[package]]
name = "rspotify"
version = "0.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eefd7bb58b714606b30a490f751d7926942e2874eef5e82934d60d7a4a68dca4"
+source = "git+https://github.com/ramsayleung/rspotify#d3e3a1fb7e3a48422312675a2f0c63444e89fc87"
dependencies = [
- "base64 0.10.1",
+ "async-trait",
+ "base64",
"chrono",
"derive_builder",
"dotenv",
- "env_logger",
- "failure",
- "itertools",
- "lazy_static",
+ "getrandom 0.2.2",
"log",
- "percent-encoding 1.0.1",
- "rand 0.6.5",
- "random",
+ "maybe-async",
"reqwest",
"serde",
- "serde_derive",
"serde_json",
- "url 1.7.2",
- "webbrowser",
+ "strum",
+ "thiserror",
+ "url",
]
[[package]]
-name = "rustc-demangle"
-version = "0.1.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
-
-[[package]]
name = "rustc-serialize"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1834,7 +1320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [
"lazy_static",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1896,9 +1382,9 @@ version = "1.0.123"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -1937,7 +1423,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de"
dependencies = [
"block-buffer",
- "cfg-if 1.0.0",
+ "cfg-if",
"cpuid-bool",
"digest",
"opaque-debug",
@@ -1976,23 +1462,23 @@ version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
name = "spotify_intersect"
version = "0.1.0"
dependencies = [
- "base64 0.13.0",
- "failure",
+ "base64",
+ "futures",
"lazy_static",
- "postgres",
"rand 0.8.3",
"rocket",
"rocket_contrib",
"rspotify",
+ "tokio",
"tokio-postgres",
]
@@ -2031,11 +1517,11 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
+ "proc-macro2",
+ "quote",
"serde",
"serde_derive",
- "syn 1.0.60",
+ "syn",
]
[[package]]
@@ -2045,13 +1531,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
dependencies = [
"base-x",
- "proc-macro2 1.0.24",
- "quote 1.0.9",
+ "proc-macro2",
+ "quote",
"serde",
"serde_derive",
"serde_json",
"sha1",
- "syn 1.0.60",
+ "syn",
]
[[package]]
@@ -2072,48 +1558,46 @@ dependencies = [
[[package]]
name = "strsim"
-version = "0.7.0"
+version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
+checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]]
-name = "subtle"
-version = "2.4.0"
+name = "strum"
+version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
+checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c"
+dependencies = [
+ "strum_macros",
+]
[[package]]
-name = "syn"
-version = "0.15.44"
+name = "strum_macros"
+version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
+checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149"
dependencies = [
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "unicode-xid 0.1.0",
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
-name = "syn"
-version = "1.0.60"
+name = "subtle"
+version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
-dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "unicode-xid 0.2.1",
-]
+checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
[[package]]
-name = "synstructure"
-version = "0.12.4"
+name = "syn"
+version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
+checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
- "unicode-xid 0.2.1",
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
]
[[package]]
@@ -2122,21 +1606,12 @@ version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"rand 0.8.3",
"redox_syscall",
"remove_dir_all",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "termcolor"
-version = "1.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
-dependencies = [
- "winapi-util",
+ "winapi",
]
[[package]]
@@ -2154,18 +1629,9 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
-]
-
-[[package]]
-name = "thread_local"
-version = "1.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"
-dependencies = [
- "once_cell",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -2175,7 +1641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -2190,7 +1656,7 @@ dependencies = [
"stdweb",
"time-macros",
"version_check",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -2210,10 +1676,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa"
dependencies = [
"proc-macro-hack",
- "proc-macro2 1.0.24",
- "quote 1.0.9",
+ "proc-macro2",
+ "quote",
"standback",
- "syn 1.0.60",
+ "syn",
]
[[package]]
@@ -2233,40 +1699,21 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
-version = "0.2.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092"
-dependencies = [
- "bytes 0.5.6",
- "fnv",
- "futures-core",
- "iovec",
- "lazy_static",
- "libc",
- "memchr",
- "mio 0.6.23",
- "mio-uds",
- "pin-project-lite 0.1.11",
- "slab",
-]
-
-[[package]]
-name = "tokio"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a"
dependencies = [
- "autocfg 1.0.1",
- "bytes 1.0.1",
+ "autocfg",
+ "bytes",
"libc",
"memchr",
- "mio 0.7.7",
+ "mio",
"num_cpus",
"once_cell",
- "pin-project-lite 0.2.4",
+ "pin-project-lite",
"signal-hook-registry",
"tokio-macros",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -2275,68 +1722,54 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "tokio-native-tls"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
+dependencies = [
+ "native-tls",
+ "tokio",
]
[[package]]
name = "tokio-postgres"
-version = "0.5.5"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "55a2482c9fe4dd481723cf5c0616f34afc710e55dcda0944e12e7b3316117892"
+checksum = "1cc9f82c2bfb06a33dd0dfb44b07ca98fe72df19e681d80c78d05a1bac2138e2"
dependencies = [
"async-trait",
"byteorder",
- "bytes 0.5.6",
+ "bytes",
"fallible-iterator",
"futures",
"log",
"parking_lot",
- "percent-encoding 2.1.0",
+ "percent-encoding",
"phf",
- "pin-project-lite 0.1.11",
+ "pin-project-lite",
"postgres-protocol",
"postgres-types",
- "tokio 0.2.25",
- "tokio-util 0.3.1",
+ "socket2",
+ "tokio",
+ "tokio-util",
]
[[package]]
name = "tokio-socks"
-version = "0.3.0"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d611fd5d241872372d52a0a3d309c52d0b95a6a67671a6c8f7ab2c4a37fb2539"
+checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0"
dependencies = [
- "bytes 0.4.12",
"either",
- "futures",
+ "futures-util",
"thiserror",
- "tokio 0.2.25",
-]
-
-[[package]]
-name = "tokio-tls"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343"
-dependencies = [
- "native-tls",
- "tokio 0.2.25",
-]
-
-[[package]]
-name = "tokio-util"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499"
-dependencies = [
- "bytes 0.5.6",
- "futures-core",
- "futures-sink",
- "log",
- "pin-project-lite 0.1.11",
- "tokio 0.2.25",
+ "tokio",
]
[[package]]
@@ -2345,12 +1778,12 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b"
dependencies = [
- "bytes 1.0.1",
+ "bytes",
"futures-core",
"futures-sink",
"log",
- "pin-project-lite 0.2.4",
- "tokio 1.2.0",
+ "pin-project-lite",
+ "tokio",
]
[[package]]
@@ -2374,9 +1807,8 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d40a22fd029e33300d8d89a5cc8ffce18bb7c587662f54629e94c9de5487f3"
dependencies = [
- "cfg-if 1.0.0",
- "log",
- "pin-project-lite 0.2.4",
+ "cfg-if",
+ "pin-project-lite",
"tracing-core",
]
@@ -2430,15 +1862,6 @@ dependencies = [
]
[[package]]
-name = "unicase"
-version = "2.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
-dependencies = [
- "version_check",
-]
-
-[[package]]
name = "unicode-bidi"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2457,10 +1880,10 @@ dependencies = [
]
[[package]]
-name = "unicode-xid"
-version = "0.1.0"
+name = "unicode-segmentation"
+version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
+checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
name = "unicode-xid"
@@ -2470,25 +1893,14 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "url"
-version = "1.7.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
-dependencies = [
- "idna 0.1.5",
- "matches",
- "percent-encoding 1.0.1",
-]
-
-[[package]]
-name = "url"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e"
dependencies = [
"form_urlencoded",
- "idna 0.2.1",
+ "idna",
"matches",
- "percent-encoding 2.1.0",
+ "percent-encoding",
]
[[package]]
@@ -2531,7 +1943,7 @@ version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"serde",
"serde_json",
"wasm-bindgen-macro",
@@ -2546,9 +1958,9 @@ dependencies = [
"bumpalo",
"lazy_static",
"log",
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
"wasm-bindgen-shared",
]
@@ -2558,7 +1970,7 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
@@ -2570,7 +1982,7 @@ version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c"
dependencies = [
- "quote 1.0.9",
+ "quote",
"wasm-bindgen-macro-support",
]
@@ -2580,9 +1992,9 @@ version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385"
dependencies = [
- "proc-macro2 1.0.24",
- "quote 1.0.9",
- "syn 1.0.60",
+ "proc-macro2",
+ "quote",
+ "syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -2604,29 +2016,6 @@ dependencies = [
]
[[package]]
-name = "webbrowser"
-version = "0.5.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a"
-dependencies = [
- "web-sys",
- "widestring",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "widestring"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
-
-[[package]]
-name = "winapi"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
-
-[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2637,27 +2026,12 @@ dependencies = [
]
[[package]]
-name = "winapi-build"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
-
-[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
-name = "winapi-util"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
-dependencies = [
- "winapi 0.3.9",
-]
-
-[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2669,17 +2043,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
dependencies = [
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "ws2_32-sys"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
-dependencies = [
- "winapi 0.2.8",
- "winapi-build",
+ "winapi",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 12ca7de..1e22336 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,12 +7,12 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-rspotify = "0.10"
+rspotify = {git = "https://github.com/ramsayleung/rspotify", features = ["env-file"]}
rocket = { git = "https://github.com/SergioBenitez/Rocket" }
rocket_contrib = { git = "https://github.com/SergioBenitez/Rocket" }
lazy_static = { version = "*"}
-postgres = "0.17"
-tokio-postgres = "0.5"
+tokio-postgres = "0.7"
+futures = "*"
+tokio = "1.2"
base64 = "0.13"
rand = "0.8"
-failure = "0.1"
diff --git a/Session.vim b/Session.vim
new file mode 100644
index 0000000..9ae7db9
--- /dev/null
+++ b/Session.vim
@@ -0,0 +1,56 @@
+let SessionLoad = 1
+let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
+let v:this_session=expand("<sfile>:p")
+silent only
+cd /srv/spotify_intersect
+if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
+ let s:wipebuf = bufnr('%')
+endif
+set shortmess=aoO
+badd +15 src/main.rs
+badd +9 src/database.rs
+badd +43 src/errors.rs
+badd +9 src/serve.rs
+badd +0 src/spotify.rs
+argglobal
+%argdel
+$argadd src/main.rs
+edit src/spotify.rs
+set splitbelow splitright
+set nosplitbelow
+set nosplitright
+wincmd t
+set winminheight=0
+set winheight=1
+set winminwidth=0
+set winwidth=1
+argglobal
+setlocal fdm=manual
+setlocal fde=0
+setlocal fmr={{{,}}}
+setlocal fdi=#
+setlocal fdl=0
+setlocal fml=1
+setlocal fdn=20
+setlocal fen
+silent! normal! zE
+let s:l = 30 - ((29 * winheight(0) + 39) / 78)
+if s:l < 1 | let s:l = 1 | endif
+exe s:l
+normal! zt
+30
+normal! 0
+tabnext 1
+if exists('s:wipebuf') && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
+ silent exe 'bwipe ' . s:wipebuf
+endif
+unlet! s:wipebuf
+set winheight=1 winwidth=20 winminheight=1 winminwidth=1 shortmess=filnxtToOFc
+let s:sx = expand("<sfile>:p:r")."x.vim"
+if file_readable(s:sx)
+ exe "source " . fnameescape(s:sx)
+endif
+let &so = s:so_save | let &siso = s:siso_save
+doautoall SessionLoadPost
+unlet SessionLoad
+" vim: set ft=vim :
diff --git a/dist/callback.html b/dist/callback.html
index 79ac83c..555bede 100644
--- a/dist/callback.html
+++ b/dist/callback.html
@@ -78,18 +78,17 @@
<button id="Connect_button" onclick="connect_button()">Connect to Spotify</button>
<button id="Load_button" onclick="load_songs()" disabled=true>Load songs to database</button>
<p id="status"></p>
- <input type="text" id="name1" placeholder="First name">
- <input type="text" id="name2" placeholder="Second name">
+ <input type="text" id="names" placeholder="Comma seperated list of usernames">
<button id="Match_button" onclick="match_users()">Match users</button>
</div>
<div class="out">
<p id="output"></p>
</div>
<script>
- const host = "http://127.0.0.1:8000";
- const api = host + "";
- //const host = "https://kobert.dev";
- //const api = host + "/spotify-api";
+ //const host = "http://127.0.0.1:8000";
+ //const api = host + "";
+ const host = "https://kobert.dev";
+ const api = host + "/spotify-api";
let lobby = null;
function getParameterByName(name) {
let url = window.location.href;
@@ -117,14 +116,16 @@
if (code !== null) {
document.getElementById("Connect_button").disabled = true;
document.getElementById("Load_button").disabled = false;
+ document.getElementById("username").disabled = false;
}
if (lobby === null) {
document.getElementById("status").innerHTML = `Error: this is no valid lobby, please create a lobby first`;
document.getElementById("Connect_button").disabled = true;
document.getElementById("Load_button").disabled = true;
+ document.getElementById("username").disabled = true;
return;
}
- fetch(api + "/user/" + lobby)
+ fetch(api + "/users/" + lobby)
.then(function (response) {
if (!response.ok) {
document.getElementById("status").innerHTML = `Error occured while loading songs: ${response.status}`;
@@ -152,10 +153,9 @@
//window.location = api + "/token/" + token;
}
function match_users() {
- let name1 = document.getElementById("name1").value;
- let name2 = document.getElementById("name2").value;
+ let names = document.getElementById("names").value;
- fetch(api + `/match/${lobby}/${name1},${name2}`)
+ fetch(api + `/match/${lobby}/${names}`)
.then(function (response) {
if (!response.ok) {
document.getElementById("status").innerHTML = `Error occured while loading songs: ${response.status}`;
diff --git a/src/database.rs b/src/database.rs
index b2cd323..ecb88d0 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -1,22 +1,19 @@
use crate::errors::Error;
-use postgres::{Client, NoTls};
use rand::prelude::*;
-use std::sync::{Arc, Mutex};
+use std::{mem::zeroed, sync::Arc};
+use tokio::sync::Mutex;
+use tokio_postgres::{Client, NoTls};
+pub static mut _client: Option<Client> = None;
lazy_static! {
- static ref CLIENT: Arc<Mutex<Client>> = Arc::new(Mutex::new(
- Client::connect(
- "host=127.0.0.1 user=spotify_intersect password=example dbname=track_db",
- NoTls
- )
- .expect("failed to connect to database")
- ));
+ static ref CLIENT: Client = unsafe { _client.take().unwrap() };
}
-pub fn initialize_db() -> Result<(), Error> {
- let mut client = CLIENT.lock()?;
- client.batch_execute(
- r#"
+pub async fn initialize_db() -> Result<(), Error> {
+ let client = &CLIENT;
+ client
+ .batch_execute(
+ r#"
CREATE TABLE IF NOT EXISTS track (
track_id SERIAL PRIMARY KEY,
track_code TEXT NOT NULL UNIQUE,
@@ -51,92 +48,105 @@ pub fn initialize_db() -> Result<(), Error> {
FROM user_track_raw
);
"#,
- )?;
+ )
+ .await?;
Ok(())
}
use rspotify::model::track::FullTrack;
-pub fn insert_track(user_id: i32, track: FullTrack, weight: i32) -> Result<(), Error> {
- let mut client = CLIENT.lock()?;
+pub async fn insert_track(user_id: i32, track: FullTrack, weight: i32) -> Result<(), Error> {
+ let client = &CLIENT;
if track.id.is_none() {
println!("{:#?}", track);
return Err("failed to load get track information".into());
}
print!(" {} ", track.id.clone()?);
- client.execute(
- "INSERT INTO track (track_code, name, artist, popularity)
+ client
+ .execute(
+ "INSERT INTO track (track_code, name, artist, popularity)
VALUES ($1, $2, $3, $4)
ON CONFLICT DO NOTHING",
- &[
- &(track.id.clone()?),
- &track.name,
- &track.artists[0].name,
- &(track.popularity as i32),
- ],
- )?;
- let track_id: i32 = client.query(
- "SELECT track_id FROM track where track_code = $1;",
- &[&(track.id?)],
- )?[0]
+ &[
+ &(track.id.clone()?),
+ &track.name,
+ &track.artists[0].name,
+ &(track.popularity as i32),
+ ],
+ )
+ .await?;
+ let track_id: i32 = client
+ .query(
+ "SELECT track_id FROM track where track_code = $1;",
+ &[&(track.id?)],
+ )
+ .await?[0]
.get(0);
println!("uid: {} tid: {}", user_id, track_id);
- client.execute(
- "
+ client
+ .execute(
+ "
INSERT INTO user_track_raw (track_id, user_id, count)
VALUES ($1, $2, $3)
ON CONFLICT
ON CONSTRAINT track_user_pkey
DO NOTHING;
",
- &[&track_id, &user_id, &0],
- )?;
- client.execute(
- "UPDATE user_track SET count = count + $3 WHERE track_id = $1 AND user_id = $2;",
- &[&track_id, &user_id, &weight],
- )?;
+ &[&track_id, &user_id, &0],
+ )
+ .await?;
+ client
+ .execute(
+ "UPDATE user_track SET count = count + $3 WHERE track_id = $1 AND user_id = $2;",
+ &[&track_id, &user_id, &weight],
+ )
+ .await?;
Ok(())
}
-pub fn insert_user(name: &str, lobby: &str) -> Result<i32, Error> {
- let mut client = CLIENT.lock()?;
- let x = get_lid(lobby, &mut *client)?;
+pub async fn insert_user(name: &str, lobby: &str) -> Result<i32, Error> {
+ let client = &CLIENT;
+ let x = get_lid(lobby, &*client).await?;
client.execute(
"INSERT INTO suser (user_name, lobby_id) VALUES ($1, $2) ON CONFLICT (user_name, lobby_id) DO NOTHING;",
&[&name, &x],
- )?;
- let db_user_id = get_uid(name, lobby, &mut *client)?;
- client.execute("DELETE FROM user_track WHERE user_id = $1;", &[&db_user_id])?;
+ ).await?;
+ let db_user_id = get_uid(name, lobby, &*client).await?;
+ client
+ .execute("DELETE FROM user_track WHERE user_id = $1;", &[&db_user_id])
+ .await?;
Ok(db_user_id)
}
-fn get_lid(lobby: &str, client: &mut postgres::Client) -> Result<i32, Error> {
+async fn get_lid(lobby: &str, client: &Client) -> Result<i32, Error> {
let x: i32 = client
- .query_one("SELECT lobby_id FROM lobby WHERE token = $1;", &[&lobby])?
+ .query_one("SELECT lobby_id FROM lobby WHERE token = $1;", &[&lobby])
+ .await?
.get(0);
Ok(x)
}
-fn get_uid(name: &str, lobby: &str, client: &mut postgres::Client) -> Result<i32, Error> {
+async fn get_uid(name: &str, lobby: &str, client: &Client) -> Result<i32, Error> {
let x: i32 = client
- .query_one("SELECT user_id FROM suser JOIN lobby USING (lobby_id) WHERE user_name = $1 AND token = $2;", &[&name, &lobby])?
+ .query_one("SELECT user_id FROM suser JOIN lobby USING (lobby_id) WHERE user_name = $1 AND token = $2;", &[&name, &lobby]).await?
.get(0);
Ok(x)
}
-pub fn match_users(lobby: String, names: &[&str]) -> Result<String, Error> {
- let mut client = CLIENT.lock()?;
+pub async fn match_users(lobby: String, names: &[&str]) -> Result<String, Error> {
+ let client = &CLIENT;
let mut songs = String::new();
let names: Vec<String> = names.iter().map(|x| x.to_string()).collect();
- let users = names
- .iter()
- .fold(String::new(), |a, name| format!("{}, ({})", a, name));
- let users: String = users.chars().skip(2).collect();
- for row in client.query(
+ //let users: Vec<&str> = names.iter().map(|x| x.as_str()).collect();
+ //println!("users to match: {:?}", users);
+ let placeholders =
+ (2..=(names.len() + 1)).fold(String::new(), |p, a| format!("{}, (${})", p, a));
+ let placeholders: String = placeholders.chars().skip(2).collect();
+ let query = format!(
"
WITH users AS (
SELECT *
- FROM ( VALUES $1 AS _ (user_id)
+ FROM ( VALUES {} ) AS _ (user_id)
)
SELECT track_id, name, artist
FROM track
@@ -146,15 +156,23 @@ pub fn match_users(lobby: String, names: &[&str]) -> Result<String, Error> {
JOIN suser USING (user_id)
JOIN track USING (track_id)
JOIN lobby USING (lobby_id)
- WHERE suser.user_name IN (SELECT * FROM users) AND track = $2
+ WHERE suser.user_name IN (SELECT * FROM users) AND token = $1
GROUP BY track_id
HAVING COUNT(track_id) = (SELECT COUNT(*) FROM users)
ORDER BY SUM(score) DESC
) AS _ USING (track_id)
;
",
- &[&users, &lobby],
- )? {
+ placeholders
+ );
+ let mut values = vec![lobby];
+ values.extend(names);
+ println!("{:?}", values);
+
+ use futures::{pin_mut, TryStreamExt};
+ let mut it = client.query_raw(query.as_str(), values).await?;
+ pin_mut!(it);
+ for row in it.try_next().await? {
let name: String = row.get(1);
let artist: String = row.get(2);
songs = format!("{}{} by {}\n", songs, name, artist);
@@ -162,33 +180,39 @@ pub fn match_users(lobby: String, names: &[&str]) -> Result<String, Error> {
Ok(songs)
}
-pub fn get_users(lobby: &str) -> Result<String, Error> {
- let mut client = CLIENT.lock()?;
+pub async fn get_users(lobby: &str) -> Result<String, Error> {
+ let client = &CLIENT;
let mut users = String::new();
- for row in client.query(
- "SELECT user_name FROM suser JOIN lobby USING (lobby_id) WHERE token = $1",
- &[&lobby],
- )? {
+ for row in client
+ .query(
+ "SELECT user_name FROM suser JOIN lobby USING (lobby_id) WHERE token = $1",
+ &[&lobby],
+ )
+ .await?
+ {
let user: String = row.get(0);
users = format!("{}{}\n", users, user);
}
Ok(users)
}
-pub fn create_lobby(name: &str) -> Result<String, Error> {
- let mut client = CLIENT.lock()?;
+pub async fn create_lobby(name: &str) -> Result<String, Error> {
+ let client = &CLIENT;
let mut token = String::new();
while token.is_empty()
|| client
.query_one("SELECT lobby_id FROM lobby WHERE token = $1", &[&token])
+ .await
.is_ok()
{
let rand: [u8; 20] = rand::thread_rng().gen();
token = base64::encode_config(&rand, base64::URL_SAFE);
}
- client.execute(
- "INSERT INTO lobby (token, lobby_name) VALUES ($1, $2);",
- &[&token, &name],
- )?;
+ client
+ .execute(
+ "INSERT INTO lobby (token, lobby_name) VALUES ($1, $2);",
+ &[&token, &name],
+ )
+ .await?;
Ok(token)
}
diff --git a/src/errors.rs b/src/errors.rs
index 544c391..d935c49 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -1,17 +1,17 @@
use rocket::http::ContentType;
use rocket::request::Request;
use rocket::response::{self, Responder, Response};
-use rspotify::client::ApiError;
-use rspotify::oauth2::SpotifyOAuth;
+use rspotify::client::ClientError;
+use rspotify::client::Spotify;
use std::collections::HashMap;
use std::io::Cursor;
use std::sync::{MutexGuard, PoisonError};
-use tokio_postgres::error::Error as DbError;
+use tokio_postgres::Error as DbError;
#[derive(Debug)]
pub enum Error {
Postgres(DbError),
- Spotify(ApiError),
+ Spotify(ClientError),
Misc(String),
}
impl From<DbError> for Error {
@@ -19,8 +19,8 @@ impl From<DbError> for Error {
Error::Postgres(error)
}
}
-impl From<ApiError> for Error {
- fn from(error: ApiError) -> Self {
+impl From<ClientError> for Error {
+ fn from(error: ClientError) -> Self {
Error::Spotify(error)
}
}
@@ -34,13 +34,13 @@ impl From<String> for Error {
Error::Misc(error)
}
}
-impl<'a> From<PoisonError<MutexGuard<'a, HashMap<String, SpotifyOAuth>>>> for Error {
- fn from(error: PoisonError<MutexGuard<'a, HashMap<String, SpotifyOAuth>>>) -> Self {
+impl<'a> From<PoisonError<MutexGuard<'a, HashMap<String, Spotify>>>> for Error {
+ fn from(error: PoisonError<MutexGuard<'a, HashMap<String, Spotify>>>) -> Self {
Error::Misc(format!("failed to lock the client mutex: {:?}", error))
}
}
-impl<'a> From<PoisonError<MutexGuard<'a, postgres::Client>>> for Error {
- fn from(error: PoisonError<MutexGuard<'a, postgres::Client>>) -> Self {
+impl<'a> From<PoisonError<MutexGuard<'a, tokio_postgres::Client>>> for Error {
+ fn from(error: PoisonError<MutexGuard<'a, tokio_postgres::Client>>) -> Self {
Error::Misc(format!("failed to lock the client mutex: {:?}", error))
}
}
diff --git a/src/main.rs b/src/main.rs
index eb5af4c..0ff4827 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,22 +10,39 @@ mod errors;
mod serve;
mod spotify;
-#[rocket::main]
-async fn main() {
- database::initialize_db().expect("failed to initialize_db");
+use tokio::runtime::Runtime;
+
+fn main() {
+ let runtime = Runtime::new().unwrap();
+ let (client, connection) = runtime
+ .block_on(tokio_postgres::connect(
+ "host=127.0.0.1 user=spotify_intersect password=example dbname=track_db",
+ tokio_postgres::NoTls,
+ ))
+ .expect("failed to connect to database");
+ unsafe {
+ database::_client = Some(client);
+ }
+ runtime.spawn(async { connection.await.unwrap() });
+
+ runtime
+ .block_on(database::initialize_db())
+ .expect("failed to initialize_db");
println!("connected with db");
- rocket::ignite()
- .mount(
- "/",
- routes![
- serve::token,
- serve::get_tracks,
- serve::match_users,
- serve::get_users,
- serve::create_lobby
- ],
+ runtime
+ .block_on(
+ rocket::ignite()
+ .mount(
+ "/",
+ routes![
+ serve::token,
+ serve::get_tracks,
+ serve::match_users,
+ serve::get_users,
+ serve::create_lobby
+ ],
+ )
+ .launch(),
)
- .launch()
- .await
.unwrap();
}
diff --git a/src/serve.rs b/src/serve.rs
index ee0e5ff..ab07607 100644
--- a/src/serve.rs
+++ b/src/serve.rs
@@ -5,8 +5,8 @@ use rocket::response::Redirect;
#[get("/callback/<name>/<lobby>/<url>")]
pub async fn get_tracks(name: String, lobby: String, url: String) -> Result<(), Error> {
- let (spotify_uid, spotify_client) = spotify::auth_user(name.as_ref(), url).await?;
- let uid = database::insert_user(spotify_uid.as_ref(), lobby.as_ref())?;
+ let (spotify_uid, spotify_client) = spotify::auth_user(name.as_ref(), url.as_str()).await?;
+ let uid = database::insert_user(spotify_uid.as_ref(), lobby.as_ref()).await?;
spotify::load_profile(uid, spotify_uid.as_ref(), spotify_client).await
}
@@ -16,20 +16,20 @@ pub fn token(name: String) -> Result<Redirect, Error> {
}
#[get("/match/<lobby>/<names>")]
-pub fn match_users(lobby: String, names: String) -> Result<String, Error> {
+pub async fn match_users(lobby: String, names: String) -> Result<String, Error> {
//let bytes = base64::decode_config(names, base64::URL_SAFE).unwrap();
//let names = String::from_utf8(bytes).unwrap();
let names: Vec<&str> = names.split(',').collect();
- database::match_users(lobby, names.as_slice())
+ database::match_users(lobby, names.as_slice()).await
}
#[get("/users/<lobby>")]
-pub fn get_users(lobby: String) -> Result<String, Error> {
- database::get_users(lobby.as_str())
+pub async fn get_users(lobby: String) -> Result<String, Error> {
+ database::get_users(lobby.as_str()).await
}
//#[post("/lobby", format = "application/json", data = "<name>")]
#[post("/lobby/<name>")]
-pub fn create_lobby(name: String) -> Result<String, Error> {
- database::create_lobby(name.as_str())
+pub async fn create_lobby(name: String) -> Result<String, Error> {
+ database::create_lobby(name.as_str()).await
}
diff --git a/src/spotify.rs b/src/spotify.rs
index 0e18c43..ea05b14 100644
--- a/src/spotify.rs
+++ b/src/spotify.rs
@@ -1,19 +1,16 @@
use crate::database;
use crate::errors::Error;
use lazy_static::lazy_static;
-use rspotify::client::{ApiError, Spotify};
-use rspotify::model::page::Page;
+use rand::{Rng, RngCore};
+use rspotify::client::{ClientError, Spotify};
+use rspotify::model::enums::TimeRange;
use rspotify::model::playlist::*;
use rspotify::model::track::*;
-use rspotify::oauth2::{SpotifyClientCredentials, SpotifyOAuth};
-use rspotify::senum::TimeRange;
-use rspotify::util::process_token;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
lazy_static! {
- static ref CACHE: Arc<Mutex<HashMap<String, SpotifyOAuth>>> =
- Arc::new(Mutex::new(HashMap::new()));
+ static ref CACHE: Arc<Mutex<HashMap<String, Spotify>>> = Arc::new(Mutex::new(HashMap::new()));
}
static CHUNK_SIZE: u32 = 50;
@@ -23,8 +20,7 @@ macro_rules! get_items {
$index = 0;
let mut result: Vec<$t> = Vec::new();
loop {
- let res: Result<Page<$t>, failure::Error> = $spotify_call.await;
- match res {
+ match $spotify_call.await {
Ok(mut page) => {
$index += CHUNK_SIZE;
if page.items.is_empty() {
@@ -32,8 +28,8 @@ macro_rules! get_items {
}
result.append(&mut page.items);
}
- Err(e) => match e.downcast::<ApiError>() {
- Ok(ApiError::RateLimited(x)) => {
+ Err(e) => match e {
+ ClientError::RateLimited(x) => {
std::thread::sleep(std::time::Duration::from_secs(x.unwrap_or(5) as u64))
}
@@ -66,22 +62,23 @@ pub async fn load_profile(db_uid: i32, spotify_uid: &str, spotify: Spotify) -> R
spotify.current_user_top_tracks(CHUNK_SIZE, index, TimeRange::MediumTerm)
);
for track in library {
- if let Err(e) = database::insert_track(db_uid, track.track, 5) {
+ if let Err(e) = database::insert_track(db_uid, track.track, 5).await {
println!("failed to load track to db: {:?}", e)
};
}
for (pos, track) in top_tracks.iter().enumerate() {
let weight = ((50.0 - pos as f64) / 50.0 * 10.0).floor() as i32;
- if let Err(e) = database::insert_track(db_uid, track.clone(), 5 + weight) {
+ if let Err(e) = database::insert_track(db_uid, track.clone(), 5 + weight).await {
println!("failed to load track to db: {:?}", e)
};
}
+ let playlists = playlists.iter().map(|x| x.clone());
for playlist in playlists {
let tracks = get_items!(
- PlaylistTrack,
+ PlaylistItem,
index,
- spotify.user_playlist_tracks(
- spotify_uid.as_ref(),
+ spotify.playlist_tracks(
+ //spotify_uid.as_ref(),
&playlist.id,
None,
CHUNK_SIZE,
@@ -89,8 +86,9 @@ pub async fn load_profile(db_uid: i32, spotify_uid: &str, spotify: Spotify) -> R
None,
)
);
- for track in tracks.iter().map(|x| x.track.clone()).flatten() {
- if let Err(e) = database::insert_track(db_uid, track, 1) {
+ let tracks: Vec<FullTrack> = tracks.iter().map(|x| x.track.clone()).flatten().collect();
+ for track in tracks {
+ if let Err(e) = database::insert_track(db_uid, track, 1).await {
println!("failed to load track to db: {:?}", e)
};
}
@@ -98,21 +96,37 @@ pub async fn load_profile(db_uid: i32, spotify_uid: &str, spotify: Spotify) -> R
Ok(())
}
-pub async fn auth_user(name: &str, url: String) -> Result<(String, Spotify), Error> {
- let mut oauth = {
- let mut guard = CACHE.lock()?;
+use rspotify::client::SpotifyBuilder;
+use rspotify::oauth2::{CredentialsBuilder, OAuthBuilder};
+
+/// Generate `length` random chars
+fn generate_random_uuid(length: usize) -> String {
+ let alphanum: &[u8] =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".as_bytes();
+ let mut buf = vec![0u8; length];
+ rand::thread_rng().fill_bytes(buf.as_mut_slice());
+ let range = alphanum.len();
+
+ buf.iter()
+ .map(|byte| alphanum[*byte as usize % range] as char)
+ .collect()
+}
+
+pub async fn auth_user(name: &str, code: &str) -> Result<(String, Spotify), Error> {
+ let mut spotify = {
+ let mut guard = (*CACHE).lock()?;
guard.remove(name)?
};
- println!("auth: {:?} url: {}", oauth, url);
- let mut token_string = format!("?code={}", url);
- let token_info = process_token(&mut oauth, &mut token_string);
- let client_credential = SpotifyClientCredentials::default()
+ println!("auth: {:?} url: {}", name, code);
+ spotify.request_user_token(code).await?;
+ //let token_info = process_token(&mut oauth, &mut token_string);
+ /*let client_credential = SpotifyClientCredentials::default()
.token_info(token_info.await?)
.build();
let spotify = Spotify::default()
- .client_credentials_manager(client_credential)
- .build();
+ .client_credentials_manager(client_credential)
+ .build();*/
let user_id = spotify
.current_user()
.await
@@ -122,13 +136,32 @@ pub async fn auth_user(name: &str, url: String) -> Result<(String, Spotify), Err
}
pub fn token(name: String) -> Result<String, Error> {
- let state = rspotify::util::generate_random_string(16);
+ let scope = "playlist-read-private playlist-read-collaborative user-read-private user-follow-read user-library-read";
+
+ let oauth = OAuthBuilder::from_env()
+ .scope(scope.split_whitespace().map(|x| x.to_owned()).collect())
+ .build()
+ .unwrap();
+ let creds = CredentialsBuilder::from_env().build().unwrap();
+
+ let spotify = SpotifyBuilder::default()
+ .credentials(creds)
+ .oauth(oauth)
+ .build()
+ .unwrap();
+
+ let auth_url = spotify.get_authorize_url(false).unwrap();
+
+ //let token = spotify.token.as_ref().unwrap();
+
+ /*let state = rspotify::util::generate_random_string(16);
let oauth = SpotifyOAuth::default();
let oauth = oauth
.scope("playlist-read-private, playlist-read-collaborative, user-read-private, user-follow-read, user-library-read")
.build();
- let auth_url = oauth.get_authorize_url(Some(&state), None);
- let mut guard = CACHE.lock()?;
- guard.insert(name, oauth);
+ */
+ //let auth_url = oauth.get_authorize_url(Some(&state), None);
+ let mut guard = (*CACHE).lock()?;
+ guard.insert(name, spotify);
Ok(auth_url)
}