From d0f13ce5f9d5ddbfac052dbcc37fd7fcb6675fa9 Mon Sep 17 00:00:00 2001 From: quininer Date: Sat, 24 Mar 2018 11:20:48 +0800 Subject: [PATCH] change: update tokio --- .travis.yml | 4 ++++ Cargo.toml | 3 --- appveyor.yml | 6 ++++-- examples/server/Cargo.toml | 4 ---- src/lib.rs | 21 +++------------------ 5 files changed, 11 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d7365a..3d5e1db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,3 +8,7 @@ os: script: - cargo test --all-features + - cd examples/server + - cargo check + - cd ../../examples/client + - cargo check diff --git a/Cargo.toml b/Cargo.toml index dbad35b..bc6d23c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,3 @@ tokio = "0.1" [features] default = [ "unstable-futures", "tokio" ] unstable-futures = [ "futures", "tokio/unstable-futures" ] - -[patch.crates-io] -tokio = { git = "https://github.com/tokio-rs/tokio" } diff --git a/appveyor.yml b/appveyor.yml index 80ae684..7ede91c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,7 @@ environment: matrix: - TARGET: x86_64-pc-windows-msvc - BITS: 64 - TARGET: i686-pc-windows-msvc - BITS: 32 install: - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe @@ -16,3 +14,7 @@ build: false test_script: - 'cargo test --all-features' + - 'cd examples/server' + - 'cargo check' + - 'cd ../../examples/client' + - 'cargo check' diff --git a/examples/server/Cargo.toml b/examples/server/Cargo.toml index 1516e92..4d164ef 100644 --- a/examples/server/Cargo.toml +++ b/examples/server/Cargo.toml @@ -11,7 +11,3 @@ tokio = { version = "0.1", features = [ "unstable-futures" ] } futures = "0.2.0-beta" clap = "2.26" - - -[patch.crates-io] -tokio = { git = "https://github.com/tokio-rs/tokio" } diff --git a/src/lib.rs b/src/lib.rs index 18b3ae2..02dcf39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -117,14 +117,7 @@ impl io::Read for TlsStream return Ok(0); } - // TODO nll - let result = { - let (io, session) = self.get_mut(); - let mut stream = Stream::new(session, io); - stream.read(buf) - }; - - match result { + match Stream::new(&mut self.session, &mut self.io).read(buf) { Ok(0) => { self.eof = true; Ok(0) }, Ok(n) => Ok(n), Err(ref e) if e.kind() == io::ErrorKind::ConnectionAborted => { @@ -142,19 +135,11 @@ impl io::Write for TlsStream where S: io::Read + io::Write, C: Session { fn write(&mut self, buf: &[u8]) -> io::Result { - let (io, session) = self.get_mut(); - let mut stream = Stream::new(session, io); - - stream.write(buf) + Stream::new(&mut self.session, &mut self.io).write(buf) } fn flush(&mut self) -> io::Result<()> { - { - let (io, session) = self.get_mut(); - let mut stream = Stream::new(session, io); - stream.flush()?; - } - + Stream::new(&mut self.session, &mut self.io).flush()?; self.io.flush() } }