From 93944055129626dbbb445f28b6bb7791cecd2578 Mon Sep 17 00:00:00 2001 From: quininer kel Date: Sat, 25 Feb 2017 12:25:09 +0800 Subject: [PATCH] [Improved] TlsStream impl poll_{read, write} --- Cargo.toml | 2 +- src/lib.rs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 33930da..f540cea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tokio-rustls" -version = "0.1.1" +version = "0.1.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 89b6873..ae56975 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -218,4 +218,20 @@ impl io::Write for TlsStream } } -impl Io for TlsStream where S: Io, C: Session {} +impl Io for TlsStream where S: Io, C: Session { + fn poll_read(&mut self) -> Async<()> { + if !self.eof && self.session.wants_read() && self.io.poll_read().is_not_ready() { + Async::NotReady + } else { + Async::Ready(()) + } + } + + fn poll_write(&mut self) -> Async<()> { + if self.session.wants_write() && self.io.poll_write().is_not_ready() { + Async::NotReady + } else { + Async::Ready(()) + } + } +}