From e49f7a89c027f6b14659279d2a308de6908e2f6f Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 29 Jun 2022 10:34:23 -0400 Subject: [PATCH] simplify futures --- Cargo.lock | 2 +- veilid-cli/src/client_api_connection.rs | 2 ++ veilid-server/Cargo.toml | 2 +- veilid-server/src/client_api.rs | 7 +++---- veilid-server/src/unix.rs | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3fa7110..badd91ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5153,7 +5153,7 @@ dependencies = [ "directories", "failure", "flume", - "futures", + "futures-util", "hostname", "lazy_static", "nix 0.24.1", diff --git a/veilid-cli/src/client_api_connection.rs b/veilid-cli/src/client_api_connection.rs index 1c722cd2..37b77555 100644 --- a/veilid-cli/src/client_api_connection.rs +++ b/veilid-cli/src/client_api_connection.rs @@ -198,8 +198,10 @@ impl ClientApiConnection { // Create the VAT network cfg_if! { if #[cfg(feature="rt-async-std")] { + use futures::AsyncReadExt; let (reader, writer) = stream.split(); } else if #[cfg(feature="rt-tokio")] { + pub use tokio_util::compat::*; let (reader, writer) = stream.into_split(); let reader = reader.compat(); let writer = writer.compat_write(); diff --git a/veilid-server/Cargo.toml b/veilid-server/Cargo.toml index 277bb1b8..b117048c 100644 --- a/veilid-server/Cargo.toml +++ b/veilid-server/Cargo.toml @@ -41,7 +41,7 @@ cfg-if = "^1" serde = "^1" serde_derive = "^1" serde_yaml = "^0" -futures = "^0" +futures-util = { version = "^0", default_features = false, features = ["alloc"] } url = "^2" ctrlc = "^3" lazy_static = "^1" diff --git a/veilid-server/src/client_api.rs b/veilid-server/src/client_api.rs index cd3310d2..348deb1d 100644 --- a/veilid-server/src/client_api.rs +++ b/veilid-server/src/client_api.rs @@ -4,8 +4,7 @@ use capnp::capability::Promise; use capnp_rpc::{pry, rpc_twoparty_capnp, twoparty, RpcSystem}; use cfg_if::*; use failure::*; -use futures::FutureExt as FuturesFutureExt; -use futures::StreamExt; +use futures_util::{future::try_join_all, FutureExt as FuturesFutureExt, StreamExt}; use std::cell::RefCell; use std::collections::HashMap; use std::net::SocketAddr; @@ -304,7 +303,7 @@ impl ClientApi { stream.set_nodelay(true)?; cfg_if! { if #[cfg(feature="rt-async-std")] { - use futures::AsyncReadExt; + use futures_util::AsyncReadExt; let (reader, writer) = stream.split(); } else if #[cfg(feature="rt-tokio")] { use tokio_util::compat::*; @@ -403,7 +402,7 @@ impl ClientApi { let bind_futures = bind_addrs .iter() .map(|addr| self.clone().handle_incoming(*addr, client.clone())); - let bind_futures_join = futures::future::try_join_all(bind_futures); + let bind_futures_join = try_join_all(bind_futures); self.inner.borrow_mut().join_handle = Some(spawn_local(bind_futures_join)); } } diff --git a/veilid-server/src/unix.rs b/veilid-server/src/unix.rs index 8a937d5a..331e64eb 100644 --- a/veilid-server/src/unix.rs +++ b/veilid-server/src/unix.rs @@ -3,7 +3,7 @@ use crate::settings::Settings; use crate::tools::*; use crate::veilid_logs::*; use clap::ArgMatches; -use futures::StreamExt; +use futures_util::StreamExt; use signal_hook::consts::signal::*; use signal_hook_async_std::Signals; use std::io::Read;