diff --git a/Cargo.toml b/Cargo.toml index 0a80d04..926e3f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,34 +25,34 @@ futures-lite = "1.11.0" once_cell = "1.4.1" [dev-dependencies] -anyhow = "1.0.32" +anyhow = "1.0.37" async-dup = "1.2.2" -async-h1 = "2.1.2" +async-h1 = "2.3.0" async-native-tls = "0.3.3" -async-std = "1.6.4" -async-tungstenite = { version = "0.8.0", features = ["async-native-tls"] } -base64 = "0.12.3" +async-std = "1.9.0" +async-tungstenite = { version = "0.12.0", features = ["async-native-tls"] } +base64 = "0.13.0" ctrlc = "3.1.6" doc-comment = "0.3.3" -futures = "0.3.5" -http = "0.2.1" -http-types = "2.4.0" -hyper = { version = "0.13.8", default-features = false, features = ["stream"] } -native-tls = "0.2.4" +futures = "0.3.8" +http = "0.2.2" +http-types = "2.9.0" +hyper = { version = "0.14.2", default-features = false, features = ["client", "http1", "server", "stream"] } +native-tls = "0.2.7" num_cpus = "1.13.0" scraper = "0.12.0" -signal-hook = "0.1.16" -surf = { version = "2.0.0-alpha.5", default-features = false, features = ["h1-client"] } -tempfile = "3.1.0" -tide = "0.13.0" -tokio = { version = "0.2.22", default-features = false, features = ["rt-threaded"] } -tungstenite = "0.11.1" -url = "2.1.1" +signal-hook = "0.3.2" +surf = { version = "2.1.0", default-features = false, features = ["h1-client"] } +tempfile = "3.2.0" +tide = "0.15.0" +tokio = { version = "1.0.1", default-features = false, features = ["rt-multi-thread"] } +tungstenite = "0.12.0" +url = "2.2.0" [target.'cfg(target_os = "linux")'.dev-dependencies] -inotify = { version = "0.8.3", default-features = false } -nix = "0.18.0" -timerfd = "1.1.1" +inotify = { version = "0.9.2", default-features = false } +nix = "0.19.1" +timerfd = "1.2.0" [target.'cfg(windows)'.dev-dependencies] uds_windows = "0.1.5" diff --git a/examples/hyper-client.rs b/examples/hyper-client.rs index ca70df2..9e9949b 100644 --- a/examples/hyper-client.rs +++ b/examples/hyper-client.rs @@ -128,11 +128,25 @@ impl tokio::io::AsyncRead for SmolStream { fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut tokio::io::ReadBuf<'_>, + ) -> Poll> { match &mut *self { - SmolStream::Plain(s) => Pin::new(s).poll_read(cx, buf), - SmolStream::Tls(s) => Pin::new(s).poll_read(cx, buf), + SmolStream::Plain(s) => { + Pin::new(s) + .poll_read(cx, buf.initialize_unfilled()) + .map_ok(|size| { + buf.advance(size); + () + }) + } + SmolStream::Tls(s) => { + Pin::new(s) + .poll_read(cx, buf.initialize_unfilled()) + .map_ok(|size| { + buf.advance(size); + () + }) + } } } } diff --git a/examples/hyper-server.rs b/examples/hyper-server.rs index d411085..41fd254 100644 --- a/examples/hyper-server.rs +++ b/examples/hyper-server.rs @@ -141,12 +141,26 @@ impl tokio::io::AsyncRead for SmolStream { fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut tokio::io::ReadBuf<'_>, + ) -> Poll> { loop { match &mut *self { - SmolStream::Plain(s) => return Pin::new(s).poll_read(cx, buf), - SmolStream::Tls(s) => return Pin::new(s).poll_read(cx, buf), + SmolStream::Plain(s) => { + return Pin::new(s) + .poll_read(cx, buf.initialize_unfilled()) + .map_ok(|size| { + buf.advance(size); + () + }) + } + SmolStream::Tls(s) => { + return Pin::new(s) + .poll_read(cx, buf.initialize_unfilled()) + .map_ok(|size| { + buf.advance(size); + () + }) + } SmolStream::Handshake(f) => { let s = smol::ready!(f.as_mut().poll(cx))?; *self = SmolStream::Tls(s); diff --git a/examples/unix-signal.rs b/examples/unix-signal.rs index 3c4b451..cbf39c1 100644 --- a/examples/unix-signal.rs +++ b/examples/unix-signal.rs @@ -8,14 +8,15 @@ #[cfg(unix)] fn main() -> std::io::Result<()> { - use std::os::unix::net::UnixStream; + use std::os::unix::{io::AsRawFd, net::UnixStream}; use smol::{prelude::*, Async}; smol::block_on(async { // Create a Unix stream that receives a byte on each signal occurrence. let (a, mut b) = Async::::pair()?; - signal_hook::pipe::register(signal_hook::SIGINT, a)?; + // Async isn't IntoRawFd, but it is AsRawFd, so let's pass the raw fd directly. + signal_hook::low_level::pipe::register_raw(signal_hook::consts::SIGINT, a.as_raw_fd())?; println!("Waiting for Ctrl-C..."); // Receive a byte that indicates the Ctrl-C signal occurred.