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", "directories",
"failure", "failure",
"flume", "flume",
"futures", "futures-util",
"hostname", "hostname",
"lazy_static", "lazy_static",
"nix 0.24.1", "nix 0.24.1",

View File

@ -198,8 +198,10 @@ impl ClientApiConnection {
// Create the VAT network // Create the VAT network
cfg_if! { cfg_if! {
if #[cfg(feature="rt-async-std")] { if #[cfg(feature="rt-async-std")] {
use futures::AsyncReadExt;
let (reader, writer) = stream.split(); let (reader, writer) = stream.split();
} else if #[cfg(feature="rt-tokio")] { } else if #[cfg(feature="rt-tokio")] {
pub use tokio_util::compat::*;
let (reader, writer) = stream.into_split(); let (reader, writer) = stream.into_split();
let reader = reader.compat(); let reader = reader.compat();
let writer = writer.compat_write(); let writer = writer.compat_write();

View File

@ -41,7 +41,7 @@ cfg-if = "^1"
serde = "^1" serde = "^1"
serde_derive = "^1" serde_derive = "^1"
serde_yaml = "^0" serde_yaml = "^0"
futures = "^0" futures-util = { version = "^0", default_features = false, features = ["alloc"] }
url = "^2" url = "^2"
ctrlc = "^3" ctrlc = "^3"
lazy_static = "^1" lazy_static = "^1"

View File

@ -4,8 +4,7 @@ use capnp::capability::Promise;
use capnp_rpc::{pry, rpc_twoparty_capnp, twoparty, RpcSystem}; use capnp_rpc::{pry, rpc_twoparty_capnp, twoparty, RpcSystem};
use cfg_if::*; use cfg_if::*;
use failure::*; use failure::*;
use futures::FutureExt as FuturesFutureExt; use futures_util::{future::try_join_all, FutureExt as FuturesFutureExt, StreamExt};
use futures::StreamExt;
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::net::SocketAddr; use std::net::SocketAddr;
@ -304,7 +303,7 @@ impl ClientApi {
stream.set_nodelay(true)?; stream.set_nodelay(true)?;
cfg_if! { cfg_if! {
if #[cfg(feature="rt-async-std")] { if #[cfg(feature="rt-async-std")] {
use futures::AsyncReadExt; use futures_util::AsyncReadExt;
let (reader, writer) = stream.split(); let (reader, writer) = stream.split();
} else if #[cfg(feature="rt-tokio")] { } else if #[cfg(feature="rt-tokio")] {
use tokio_util::compat::*; use tokio_util::compat::*;
@ -403,7 +402,7 @@ impl ClientApi {
let bind_futures = bind_addrs let bind_futures = bind_addrs
.iter() .iter()
.map(|addr| self.clone().handle_incoming(*addr, client.clone())); .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)); 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::tools::*;
use crate::veilid_logs::*; use crate::veilid_logs::*;
use clap::ArgMatches; use clap::ArgMatches;
use futures::StreamExt; use futures_util::StreamExt;
use signal_hook::consts::signal::*; use signal_hook::consts::signal::*;
use signal_hook_async_std::Signals; use signal_hook_async_std::Signals;
use std::io::Read; use std::io::Read;