[Improved] TlsStream impl poll_{read, write}

This commit is contained in:
quininer kel 2017-02-25 12:25:09 +08:00
parent ffdf1ebcb8
commit 9394405512
2 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "tokio-rustls"
version = "0.1.1"
version = "0.1.2"
authors = ["quininer kel <quininer@live.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/quininer/tokio-rustls"

View File

@ -218,4 +218,20 @@ impl<S, C> io::Write for TlsStream<S, C>
}
}
impl<S, C> Io for TlsStream<S, C> where S: Io, C: Session {}
impl<S, C> Io for TlsStream<S, C> 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(())
}
}
}