diff --git a/Cargo.toml b/Cargo.toml index 350b8c9..0e05744 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,8 @@ async-std = "1.5.0" async-tungstenite = { version = "0.4.2", features = ["async-native-tls"] } base64 = "0.12.0" ctrlc = "3.1.4" -futures = "0.3.4" +futures = "0.3.5" +futures-lite = { path = "../futures-lite" } http = "0.2.1" http-types = "1.2.0" hyper = { version = "0.13.5", default-features = false, features = ["stream"] } diff --git a/examples/async-h1-client.rs b/examples/async-h1-client.rs index 645b0e3..2b1f5bd 100644 --- a/examples/async-h1-client.rs +++ b/examples/async-h1-client.rs @@ -11,7 +11,7 @@ use std::net::{TcpStream, ToSocketAddrs}; use anyhow::{bail, Context as _, Error, Result}; use async_io::Async; use blocking::{block_on, unblock}; -use futures::prelude::*; +use futures_lite::*; use http_types::{Method, Request, Response}; use url::Url; diff --git a/examples/async-h1-server.rs b/examples/async-h1-server.rs index dfd468d..ec34a65 100644 --- a/examples/async-h1-server.rs +++ b/examples/async-h1-server.rs @@ -19,7 +19,7 @@ use anyhow::Result; use async_io::Async; use async_native_tls::{Identity, TlsAcceptor}; use blocking::block_on; -use futures::prelude::*; +use futures_lite::*; use http_types::{Request, Response, StatusCode}; use smol::Task; diff --git a/examples/chat-client.rs b/examples/chat-client.rs index e69597c..1085863 100644 --- a/examples/chat-client.rs +++ b/examples/chat-client.rs @@ -16,8 +16,7 @@ use std::net::TcpStream; use async_io::Async; use blocking::{block_on, Unblock}; -use futures::io; -use futures::prelude::*; +use futures_lite::*; fn main() -> io::Result<()> { block_on(async { @@ -35,10 +34,19 @@ fn main() -> io::Result<()> { let mut writer = &stream; // Wait until the standard input is closed or the connection is closed. - futures::select! { - _ = io::copy(stdin, &mut writer).fuse() => println!("Quit!"), - _ = io::copy(reader, &mut stdout).fuse() => println!("Server disconnected!"), - } + future::race( + async { + let res = io::copy(stdin, &mut writer).await; + println!("Quit!"); + res + }, + async { + let res = io::copy(reader, &mut stdout).await; + println!("Server disconnected!"); + res + }, + ) + .await?; Ok(()) }) diff --git a/examples/chat-server.rs b/examples/chat-server.rs index 7ea38fe..1d78c86 100644 --- a/examples/chat-server.rs +++ b/examples/chat-server.rs @@ -19,8 +19,7 @@ use async_channel::{bounded, Receiver, Sender}; use async_dup::Arc; use async_io::Async; use blocking::block_on; -use futures::io::{self, BufReader}; -use futures::prelude::*; +use futures_lite::*; use smol::Task; /// An event on the chat server. @@ -70,7 +69,7 @@ async fn dispatch(receiver: Receiver) -> io::Result<()> { /// Reads messages from the client and forwards them to the dispatcher task. async fn read_messages(sender: Sender, client: Arc>) -> io::Result<()> { let addr = client.get_ref().peer_addr()?; - let mut lines = BufReader::new(client).lines(); + let mut lines = io::BufReader::new(client).lines(); while let Some(line) = lines.next().await { let line = line?; diff --git a/examples/ctrl-c.rs b/examples/ctrl-c.rs index bf7e57e..a71daef 100644 --- a/examples/ctrl-c.rs +++ b/examples/ctrl-c.rs @@ -7,13 +7,13 @@ //! ``` use blocking::block_on; -use futures::prelude::*; +use futures_lite::*; fn main() { // Set a handler that sends a message through a channel. let (s, ctrl_c) = async_channel::bounded(100); let handle = move || { - let _ = s.send(()).now_or_never(); + let _ = future::poll_once(s.send(())); }; ctrlc::set_handler(handle).unwrap(); diff --git a/examples/hyper-client.rs b/examples/hyper-client.rs index f3ba818..5d3487c 100644 --- a/examples/hyper-client.rs +++ b/examples/hyper-client.rs @@ -16,7 +16,7 @@ use anyhow::{bail, Context as _, Error, Result}; use async_io::Async; use async_native_tls::TlsStream; use blocking::{block_on, unblock}; -use futures::prelude::*; +use futures_lite::*; use http::Uri; use hyper::{Body, Client, Request, Response}; use smol::Task; @@ -42,7 +42,7 @@ fn main() -> Result<()> { // Read the message body. let body = resp .into_body() - .try_fold(Vec::new(), |mut body, chunk| async move { + .try_fold(Vec::new(), |mut body, chunk| { body.extend_from_slice(&chunk); Ok(body) }) @@ -70,7 +70,7 @@ struct SmolConnector; impl hyper::service::Service for SmolConnector { type Response = SmolStream; type Error = Error; - type Future = future::BoxFuture<'static, Result>; + type Future = Pin> + Send>>; fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) diff --git a/examples/hyper-server.rs b/examples/hyper-server.rs index 0073894..381a2a9 100644 --- a/examples/hyper-server.rs +++ b/examples/hyper-server.rs @@ -23,7 +23,7 @@ use anyhow::{Error, Result}; use async_io::Async; use async_native_tls::{Identity, TlsAcceptor, TlsStream}; use blocking::block_on; -use futures::prelude::*; +use futures_lite::*; use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Request, Response, Server}; use smol::Task; @@ -103,7 +103,7 @@ impl hyper::server::accept::Accept for SmolListener { cx: &mut Context, ) -> Poll>> { let poll = Pin::new(&mut self.listener.incoming()).poll_next(cx); - let stream = futures::ready!(poll).unwrap()?; + let stream = ready!(poll).unwrap()?; let stream = match &self.tls { None => SmolStream::Plain(stream), @@ -132,7 +132,7 @@ enum SmolStream { Tls(TlsStream>), /// A TCP connection that is in process of getting secured by TLS. - Handshake(future::BoxFuture<'static, io::Result>>>), + Handshake(Pin>>> + Send>>), } impl hyper::client::connect::Connection for SmolStream { @@ -152,7 +152,7 @@ impl tokio::io::AsyncRead for SmolStream { SmolStream::Plain(s) => return Pin::new(s).poll_read(cx, buf), SmolStream::Tls(s) => return Pin::new(s).poll_read(cx, buf), SmolStream::Handshake(f) => { - let s = futures::ready!(f.as_mut().poll(cx))?; + let s = ready!(f.as_mut().poll(cx))?; *self = SmolStream::Tls(s); } } @@ -171,7 +171,7 @@ impl tokio::io::AsyncWrite for SmolStream { SmolStream::Plain(s) => return Pin::new(s).poll_write(cx, buf), SmolStream::Tls(s) => return Pin::new(s).poll_write(cx, buf), SmolStream::Handshake(f) => { - let s = futures::ready!(f.as_mut().poll(cx))?; + let s = ready!(f.as_mut().poll(cx))?; *self = SmolStream::Tls(s); } } diff --git a/examples/simple-client.rs b/examples/simple-client.rs index e0b9acf..534fb35 100644 --- a/examples/simple-client.rs +++ b/examples/simple-client.rs @@ -11,7 +11,7 @@ use std::net::{TcpStream, ToSocketAddrs}; use anyhow::{bail, Context as _, Result}; use async_io::Async; use blocking::{block_on, unblock}; -use futures::prelude::*; +use futures_lite::*; use url::Url; /// Sends a GET request and fetches the response. diff --git a/examples/simple-server.rs b/examples/simple-server.rs index 48c6302..3dfcaf5 100644 --- a/examples/simple-server.rs +++ b/examples/simple-server.rs @@ -19,7 +19,7 @@ use anyhow::Result; use async_io::Async; use async_native_tls::{Identity, TlsAcceptor}; use blocking::block_on; -use futures::prelude::*; +use futures_lite::*; use smol::Task; const RESPONSE: &[u8] = br#" diff --git a/examples/tcp-client.rs b/examples/tcp-client.rs index d0d82c5..aadafde 100644 --- a/examples/tcp-client.rs +++ b/examples/tcp-client.rs @@ -16,8 +16,7 @@ use std::net::TcpStream; use async_io::Async; use blocking::{block_on, Unblock}; -use futures::io; -use futures::prelude::*; +use futures_lite::*; fn main() -> io::Result<()> { block_on(async { diff --git a/examples/tcp-server.rs b/examples/tcp-server.rs index 98a0926..e61063e 100644 --- a/examples/tcp-server.rs +++ b/examples/tcp-server.rs @@ -16,7 +16,7 @@ use std::net::{TcpListener, TcpStream}; use async_io::Async; use blocking::block_on; -use futures::io; +use futures_lite::*; use smol::Task; /// Echoes messages from the client back to it. diff --git a/examples/tls-client.rs b/examples/tls-client.rs index e635bf7..bc57de2 100644 --- a/examples/tls-client.rs +++ b/examples/tls-client.rs @@ -18,8 +18,7 @@ use anyhow::Result; use async_io::Async; use async_native_tls::{Certificate, TlsConnector}; use blocking::{block_on, Unblock}; -use futures::io; -use futures::prelude::*; +use futures_lite::*; fn main() -> Result<()> { // Initialize TLS with the local certificate. diff --git a/examples/tls-server.rs b/examples/tls-server.rs index a08acec..a7ff32b 100644 --- a/examples/tls-server.rs +++ b/examples/tls-server.rs @@ -18,7 +18,7 @@ use anyhow::Result; use async_io::Async; use async_native_tls::{Identity, TlsAcceptor, TlsStream}; use blocking::block_on; -use futures::io; +use futures_lite::*; use smol::Task; /// Echoes messages from the client back to it. diff --git a/examples/unix-signal.rs b/examples/unix-signal.rs index 45ae5c0..5d4d681 100644 --- a/examples/unix-signal.rs +++ b/examples/unix-signal.rs @@ -12,7 +12,7 @@ fn main() -> std::io::Result<()> { use async_io::Async; use blocking::block_on; - use futures::prelude::*; + use futures_lite::*; block_on(async { // Create a Unix stream that receives a byte on each signal occurrence. diff --git a/examples/websocket-client.rs b/examples/websocket-client.rs index 9375a57..4d32c5d 100644 --- a/examples/websocket-client.rs +++ b/examples/websocket-client.rs @@ -21,7 +21,8 @@ use async_io::Async; use async_native_tls::{Certificate, TlsConnector, TlsStream}; use async_tungstenite::WebSocketStream; use blocking::{block_on, unblock}; -use futures::prelude::*; +use futures::sink::{Sink, SinkExt}; +use futures_lite::*; use tungstenite::handshake::client::Response; use tungstenite::Message; use url::Url; diff --git a/examples/websocket-server.rs b/examples/websocket-server.rs index f756458..93a942e 100644 --- a/examples/websocket-server.rs +++ b/examples/websocket-server.rs @@ -21,7 +21,8 @@ use async_io::Async; use async_native_tls::{Identity, TlsAcceptor, TlsStream}; use async_tungstenite::WebSocketStream; use blocking::block_on; -use futures::prelude::*; +use futures::sink::{Sink, SinkExt}; +use futures_lite::*; use smol::Task; use tungstenite::Message; diff --git a/examples/windows-uds.rs b/examples/windows-uds.rs index 2f1a34b..a1e3138 100644 --- a/examples/windows-uds.rs +++ b/examples/windows-uds.rs @@ -12,8 +12,7 @@ fn main() -> std::io::Result<()> { use async_io::Async; use blocking::{block_on, Unblock}; - use futures::io; - use futures::prelude::*; + use futures_lite::*; use smol::Task; use tempfile::tempdir; use uds_windows::{UnixListener, UnixStream};