From 076c266fa1340a6e02eaec5352fa9ea69c9b36bc Mon Sep 17 00:00:00 2001 From: quininer kel Date: Fri, 26 May 2017 18:22:03 +0800 Subject: [PATCH] [Changed] bump version --- Cargo.toml | 2 +- src/lib.rs | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 438c91b..863d8cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tokio-rustls" -version = "0.2.1" +version = "0.2.2" authors = ["quininer kel "] license = "MIT/Apache-2.0" repository = "https://github.com/quininer/tokio-rustls" diff --git a/src/lib.rs b/src/lib.rs index 2c6a7e9..4e3a47f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,12 +46,11 @@ impl ClientConfigExt for Arc { -> ConnectAsync where S: AsyncRead + AsyncWrite { - ConnectAsync(MidHandshake { - inner: Some(TlsStream::new(stream, ClientSession::new(self, domain))) - }) + connect_async_with_session(stream, ClientSession::new(self, domain)) } } +#[inline] pub fn connect_async_with_session(stream: S, session: ClientSession) -> ConnectAsync where S: AsyncRead + AsyncWrite @@ -66,12 +65,11 @@ impl ServerConfigExt for Arc { -> AcceptAsync where S: AsyncRead + AsyncWrite { - AcceptAsync(MidHandshake { - inner: Some(TlsStream::new(stream, ServerSession::new(self))) - }) + accept_async_with_session(stream, ServerSession::new(self)) } } +#[inline] pub fn accept_async_with_session(stream: S, session: ServerSession) -> AcceptAsync where S: AsyncRead + AsyncWrite @@ -227,7 +225,7 @@ impl io::Write for TlsStream where S: AsyncRead + AsyncWrite, C: Session { fn write(&mut self, buf: &[u8]) -> io::Result { - if buf.len() == 0 { + if buf.is_empty() { return Ok(0); } @@ -237,14 +235,12 @@ impl io::Write for TlsStream while self.session.wants_write() { match self.session.write_tls(&mut self.io) { Ok(_) => (), - Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { - if output == 0 { - // Both rustls buffer and IO buffer are blocking. - return Err(io::Error::from(io::ErrorKind::WouldBlock)); - } else { - break; - } - } + Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => if output == 0 { + // Both rustls buffer and IO buffer are blocking. + return Err(io::Error::from(io::ErrorKind::WouldBlock)); + } else { + break; + }, Err(e) => return Err(e) } }