From c393236dfd12c13e82badd631d3a3a90481c6f95 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 13 Aug 2020 20:15:01 -0700 Subject: io: change AsyncRead to use a ReadBuf (#2758) Works towards #2716. Changes the argument to `AsyncRead::poll_read` to take a `ReadBuf` struct that safely manages writes to uninitialized memory. --- tokio/src/net/tcp/split.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tokio/src/net/tcp/split.rs') diff --git a/tokio/src/net/tcp/split.rs b/tokio/src/net/tcp/split.rs index 0c1e359f..9d99d7bd 100644 --- a/tokio/src/net/tcp/split.rs +++ b/tokio/src/net/tcp/split.rs @@ -9,12 +9,11 @@ //! level. use crate::future::poll_fn; -use crate::io::{AsyncRead, AsyncWrite}; +use crate::io::{AsyncRead, AsyncWrite, ReadBuf}; use crate::net::TcpStream; use bytes::Buf; use std::io; -use std::mem::MaybeUninit; use std::net::Shutdown; use std::pin::Pin; use std::task::{Context, Poll}; @@ -131,15 +130,11 @@ impl ReadHalf<'_> { } impl AsyncRead for ReadHalf<'_> { - unsafe fn prepare_uninitialized_buffer(&self, _: &mut [MaybeUninit]) -> bool { - false - } - fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut ReadBuf<'_>, + ) -> Poll> { self.0.poll_read_priv(cx, buf) } } -- cgit v1.2.3