From 4d673f9a72cab0be1fe50bbcb648d218ad924a20 Mon Sep 17 00:00:00 2001 From: quininer Date: Sat, 18 May 2019 23:44:29 +0800 Subject: [PATCH] update iovec --- Cargo.toml | 4 +--- src/common/mod.rs | 11 ++++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f892061..8a44728 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,9 +17,7 @@ appveyor = { repository = "quininer/tokio-rustls" } [dependencies] smallvec = "*" -futures = { package = "futures-preview", version = "0.3.0-alpha.15" } -bytes = "0.4" -iovec = "0.1" +futures = { package = "futures-preview", version = "0.3.0-alpha.16" } rustls = "0.15" webpki = "0.19" diff --git a/src/common/mod.rs b/src/common/mod.rs index dabdcbc..98afcd6 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -7,7 +7,7 @@ use std::io::{ self, Read }; use rustls::Session; use rustls::WriteV; use futures::task::Context; -use futures::io::{ AsyncRead, AsyncWrite, IoVec }; +use futures::io::{ AsyncRead, AsyncWrite, IoSlice }; use smallvec::SmallVec; @@ -159,13 +159,10 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> WriteTls for Str fn writev(&mut self, vbytes: &[&[u8]]) -> io::Result { let vbytes = vbytes .into_iter() - .try_fold(SmallVec::<[&'_ IoVec; 16]>::new(), |mut sum, next| { - sum.push(IoVec::from_bytes(next)?); - Some(sum) - }) - .unwrap_or_default(); + .map(|v| IoSlice::new(v)) + .collect::; 64]>>(); - 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::Pending => Err(io::ErrorKind::WouldBlock.into()) }