update iovec

This commit is contained in:
quininer 2019-05-18 23:44:29 +08:00
parent 4cc374fd4c
commit 4d673f9a72
2 changed files with 5 additions and 10 deletions

View File

@ -17,9 +17,7 @@ appveyor = { repository = "quininer/tokio-rustls" }
[dependencies] [dependencies]
smallvec = "*" smallvec = "*"
futures = { package = "futures-preview", version = "0.3.0-alpha.15" } futures = { package = "futures-preview", version = "0.3.0-alpha.16" }
bytes = "0.4"
iovec = "0.1"
rustls = "0.15" rustls = "0.15"
webpki = "0.19" webpki = "0.19"

View File

@ -7,7 +7,7 @@ use std::io::{ self, Read };
use rustls::Session; use rustls::Session;
use rustls::WriteV; use rustls::WriteV;
use futures::task::Context; use futures::task::Context;
use futures::io::{ AsyncRead, AsyncWrite, IoVec }; use futures::io::{ AsyncRead, AsyncWrite, IoSlice };
use smallvec::SmallVec; use smallvec::SmallVec;
@ -159,13 +159,10 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> WriteTls<IO, S> for Str
fn writev(&mut self, vbytes: &[&[u8]]) -> io::Result<usize> { fn writev(&mut self, vbytes: &[&[u8]]) -> io::Result<usize> {
let vbytes = vbytes let vbytes = vbytes
.into_iter() .into_iter()
.try_fold(SmallVec::<[&'_ IoVec; 16]>::new(), |mut sum, next| { .map(|v| IoSlice::new(v))
sum.push(IoVec::from_bytes(next)?); .collect::<SmallVec<[IoSlice<'_>; 64]>>();
Some(sum)
})
.unwrap_or_default();
match Pin::new(&mut self.io).poll_vectored_write(self.cx, &vbytes) { match Pin::new(&mut self.io).poll_write_vectored(self.cx, &vbytes) {
Poll::Ready(result) => result, Poll::Ready(result) => result,
Poll::Pending => Err(io::ErrorKind::WouldBlock.into()) Poll::Pending => Err(io::ErrorKind::WouldBlock.into())
} }