Remove remaining async-std
dependencies from collab
This commit is contained in:
parent
dec88a42e7
commit
b4ae2b20a0
5 changed files with 30 additions and 50 deletions
41
Cargo.lock
generated
41
Cargo.lock
generated
|
@ -307,17 +307,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-rustls"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9c86f33abd5a4f3e2d6d9251a9e0c6a7e52eb1113caf893dae8429bf4a53f378"
|
|
||||||
dependencies = [
|
|
||||||
"futures-lite",
|
|
||||||
"rustls",
|
|
||||||
"webpki",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-std"
|
name = "async-std"
|
||||||
version = "1.9.0"
|
version = "1.9.0"
|
||||||
|
@ -328,7 +317,6 @@ dependencies = [
|
||||||
"async-global-executor",
|
"async-global-executor",
|
||||||
"async-io",
|
"async-io",
|
||||||
"async-lock",
|
"async-lock",
|
||||||
"async-process",
|
|
||||||
"crossbeam-utils 0.8.2",
|
"crossbeam-utils 0.8.2",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
@ -4568,6 +4556,7 @@ dependencies = [
|
||||||
"stringprep",
|
"stringprep",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time 0.2.27",
|
"time 0.2.27",
|
||||||
|
"tokio-stream",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
"webpki",
|
"webpki",
|
||||||
|
@ -4601,8 +4590,9 @@ version = "0.5.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057"
|
checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-rustls",
|
"once_cell",
|
||||||
"async-std",
|
"tokio",
|
||||||
|
"tokio-rustls",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5078,6 +5068,28 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-rustls"
|
||||||
|
version = "0.22.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
|
||||||
|
dependencies = [
|
||||||
|
"rustls",
|
||||||
|
"tokio",
|
||||||
|
"webpki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-stream"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"pin-project-lite 0.2.8",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-tungstenite"
|
name = "tokio-tungstenite"
|
||||||
version = "0.17.1"
|
version = "0.17.1"
|
||||||
|
@ -5500,7 +5512,6 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"surf",
|
|
||||||
"tempdir",
|
"tempdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ toml = "0.5.8"
|
||||||
|
|
||||||
[dependencies.sqlx]
|
[dependencies.sqlx]
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
features = ["runtime-async-std-rustls", "postgres", "time", "uuid"]
|
features = ["runtime-tokio-rustls", "postgres", "time", "uuid"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
collections = { path = "../collections", features = ["test-support"] }
|
collections = { path = "../collections", features = ["test-support"] }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use db::{Db, UserId};
|
use db::{Db, PostgresDb, UserId};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use time::{Duration, OffsetDateTime};
|
use time::{Duration, OffsetDateTime};
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ use time::{Duration, OffsetDateTime};
|
||||||
#[path = "../db.rs"]
|
#[path = "../db.rs"]
|
||||||
mod db;
|
mod db;
|
||||||
|
|
||||||
#[async_std::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let mut rng = StdRng::from_entropy();
|
let mut rng = StdRng::from_entropy();
|
||||||
let database_url = std::env::var("DATABASE_URL").expect("missing DATABASE_URL env var");
|
let database_url = std::env::var("DATABASE_URL").expect("missing DATABASE_URL env var");
|
||||||
let db = Db::new(&database_url, 5)
|
let db = PostgresDb::new(&database_url, 5)
|
||||||
.await
|
.await
|
||||||
.expect("failed to connect to postgres database");
|
.expect("failed to connect to postgres database");
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ anyhow = "1.0.38"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
rand = { version = "0.8", optional = true }
|
rand = { version = "0.8", optional = true }
|
||||||
surf = "2.2"
|
|
||||||
tempdir = { version = "0.3.7", optional = true }
|
tempdir = { version = "0.3.7", optional = true }
|
||||||
serde_json = { version = "1.0.64", features = [
|
serde_json = { version = "1.0.64", features = [
|
||||||
"preserve_order",
|
"preserve_order",
|
||||||
|
|
|
@ -153,33 +153,3 @@ mod tests {
|
||||||
assert_eq!(vec, &[1000, 101, 21, 19, 17, 13, 9, 8]);
|
assert_eq!(vec, &[1000, 101, 21, 19, 17, 13, 9, 8]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow surf Results to accept context like other Results do when
|
|
||||||
// using anyhow.
|
|
||||||
pub trait SurfResultExt {
|
|
||||||
fn context<C>(self, cx: C) -> Self
|
|
||||||
where
|
|
||||||
C: std::fmt::Display + Send + Sync + 'static;
|
|
||||||
|
|
||||||
fn with_context<C, F>(self, f: F) -> Self
|
|
||||||
where
|
|
||||||
C: std::fmt::Display + Send + Sync + 'static,
|
|
||||||
F: FnOnce() -> C;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> SurfResultExt for surf::Result<T> {
|
|
||||||
fn context<C>(self, cx: C) -> Self
|
|
||||||
where
|
|
||||||
C: std::fmt::Display + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
self.map_err(|e| surf::Error::new(e.status(), e.into_inner().context(cx)))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn with_context<C, F>(self, f: F) -> Self
|
|
||||||
where
|
|
||||||
C: std::fmt::Display + Send + Sync + 'static,
|
|
||||||
F: FnOnce() -> C,
|
|
||||||
{
|
|
||||||
self.map_err(|e| surf::Error::new(e.status(), e.into_inner().context(f())))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue