Remove remaining async-std dependencies from collab

This commit is contained in:
Antonio Scandurra
2022-04-26 19:47:40 +02:00
parent dec88a42e7
commit b4ae2b20a0
5 changed files with 30 additions and 50 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ toml = "0.5.8"
[dependencies.sqlx]
version = "0.5.2"
features = ["runtime-async-std-rustls", "postgres", "time", "uuid"]
features = ["runtime-tokio-rustls", "postgres", "time", "uuid"]
[dev-dependencies]
collections = { path = "../collections", features = ["test-support"] }
+3 -3
View File
@@ -1,4 +1,4 @@
use db::{Db, UserId};
use db::{Db, PostgresDb, UserId};
use rand::prelude::*;
use time::{Duration, OffsetDateTime};
@@ -6,11 +6,11 @@ use time::{Duration, OffsetDateTime};
#[path = "../db.rs"]
mod db;
#[async_std::main]
#[tokio::main]
async fn main() {
let mut rng = StdRng::from_entropy();
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
.expect("failed to connect to postgres database");
-1
View File
@@ -14,7 +14,6 @@ anyhow = "1.0.38"
futures = "0.3"
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
rand = { version = "0.8", optional = true }
surf = "2.2"
tempdir = { version = "0.3.7", optional = true }
serde_json = { version = "1.0.64", features = [
"preserve_order",
-30
View File
@@ -153,33 +153,3 @@ mod tests {
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())))
}
}