Fix incorrect prepare_uninitialized_buffer

This commit is contained in:
quininer 2019-12-08 00:59:15 +08:00
parent 074fe4a5ac
commit 7f69e889a4
3 changed files with 8 additions and 2 deletions

View File

@ -24,6 +24,7 @@ webpki = "0.21"
[features] [features]
early-data = [] early-data = []
dangerous_configuration = ["rustls/dangerous_configuration"] dangerous_configuration = ["rustls/dangerous_configuration"]
unstable = []
[dev-dependencies] [dev-dependencies]
tokio = { version = "0.2.0", features = ["macros", "net", "io-util", "rt-core", "time"] } tokio = { version = "0.2.0", features = ["macros", "net", "io-util", "rt-core", "time"] }

View File

@ -69,8 +69,9 @@ impl<IO> AsyncRead for TlsStream<IO>
where where
IO: AsyncRead + AsyncWrite + Unpin, IO: AsyncRead + AsyncWrite + Unpin,
{ {
#[cfg(feature = "unstable")]
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [std::mem::MaybeUninit<u8>]) -> bool { unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
self.io.prepare_uninitialized_buffer(buf) false
} }
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<io::Result<usize>> { fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<io::Result<usize>> {

View File

@ -67,8 +67,12 @@ impl<IO> AsyncRead for TlsStream<IO>
where where
IO: AsyncRead + AsyncWrite + Unpin, IO: AsyncRead + AsyncWrite + Unpin,
{ {
#[cfg(feature = "unstable")]
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [std::mem::MaybeUninit<u8>]) -> bool { unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
self.io.prepare_uninitialized_buffer(buf) // TODO
//
// https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.initializer
false
} }
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<io::Result<usize>> { fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<io::Result<usize>> {