diff --git a/Cargo.toml b/Cargo.toml index 4d8e7f4..d3b3219 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ exclude = ["/.github", "/examples", "/scripts"] [dependencies] tokio = "1.0" rustls = { version = "0.23.5", default-features = false, features = ["std"] } -pin-project-lite = "0.2.14" pki-types = { package = "rustls-pki-types", version = "1" } [features] @@ -35,3 +34,4 @@ futures-util = "0.3.1" lazy_static = "1.1" webpki-roots = "0.26" rustls-pemfile = "2" +pin-project-lite = "0.2.14" diff --git a/src/server.rs b/src/server.rs index 4ce4f3d..f371f46 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,5 +1,4 @@ use std::io; -use std::io::Read; #[cfg(unix)] use std::os::unix::io::{AsRawFd, RawFd}; #[cfg(windows)] @@ -107,6 +106,8 @@ where cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll> { + use std::io::Read; + let this = self.get_mut(); let mut stream = Stream::new(&mut this.io, &mut this.session).set_eof(!this.state.readable()); @@ -132,11 +133,13 @@ where if let Some(mut early_data) = stream.session.early_data() { match early_data.read(buf.initialize_unfilled()) { - Ok(n) => if n > 0 { - buf.advance(n); - return Poll::Ready(Ok(())); + Ok(n) => { + if n > 0 { + buf.advance(n); + return Poll::Ready(Ok(())); + } } - Err(err) => return Poll::Ready(Err(err)) + Err(err) => return Poll::Ready(Err(err)), } } @@ -144,7 +147,7 @@ where return Poll::Pending; } - return Poll::Ready(Ok(())); + Poll::Ready(Ok(())) } TlsState::ReadShutdown | TlsState::FullyShutdown => Poll::Ready(Ok(())), s => unreachable!("server TLS can not hit this state: {:?}", s), diff --git a/tests/early-data.rs b/tests/early-data.rs index c754054..aa8e070 100644 --- a/tests/early-data.rs +++ b/tests/early-data.rs @@ -42,8 +42,13 @@ pin_project! { impl AsyncRead for TlsStreamEarlyWrapper where - IO: AsyncRead + AsyncWrite + Unpin { - fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll> { + IO: AsyncRead + AsyncWrite + Unpin, +{ + fn poll_read( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + buf: &mut ReadBuf<'_>, + ) -> Poll> { return self.project().inner.poll_read_early_data(cx, buf); } } @@ -103,7 +108,7 @@ async fn test_0rtt_impl(vectored: bool) -> io::Result<()> { let stream = acceptor.accept(&mut sock).await.unwrap(); let mut buf = Vec::new(); - let mut stream_wrapper = TlsStreamEarlyWrapper{ inner: stream }; + let mut stream_wrapper = TlsStreamEarlyWrapper { inner: stream }; stream_wrapper.read_to_end(&mut buf).await.unwrap(); let mut stream = stream_wrapper.inner; stream.write_all(b"EARLY:").await.unwrap();