simplify futures

This commit is contained in:
John Smith 2022-06-29 10:34:23 -04:00
parent 018d7da429
commit e49f7a89c0
5 changed files with 8 additions and 7 deletions

2
Cargo.lock generated
View File

@ -5153,7 +5153,7 @@ dependencies = [
"directories",
"failure",
"flume",
"futures",
"futures-util",
"hostname",
"lazy_static",
"nix 0.24.1",

View File

@ -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();

View File

@ -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"

View File

@ -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));
}
}

View File

@ -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;