From 0db05aa9bfa71e4d9127b36fab9c99040b44e784 Mon Sep 17 00:00:00 2001 From: quininer kel Date: Wed, 1 Mar 2017 10:34:24 +0800 Subject: [PATCH] [Changed] proto {Server,Client}::new use Arc --- Cargo.toml | 2 +- src/lib.rs | 8 +++++--- src/proto.rs | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f540cea..bf70636 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tokio-rustls" -version = "0.1.2" +version = "0.1.3" 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 e815aff..e6f5856 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ impl Future for MidHandshake fn poll(&mut self) -> Poll { loop { - let stream = self.inner.as_mut().unwrap_or_else(|| unreachable!()); + let stream = self.inner.as_mut().unwrap(); if !stream.session.is_handshaking() { break }; match stream.do_io() { @@ -111,7 +111,7 @@ impl Future for MidHandshake } } - Ok(Async::Ready(self.inner.take().unwrap_or_else(|| unreachable!()))) + Ok(Async::Ready(self.inner.take().unwrap())) } } @@ -228,4 +228,6 @@ impl io::Write for TlsStream } } -impl Io for TlsStream where S: Io, C: Session {} +impl Io for TlsStream where S: Io, C: Session { + // TODO impl poll_{read, write} +} diff --git a/src/proto.rs b/src/proto.rs index 24a8541..c1b60d4 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -41,10 +41,10 @@ impl Server { /// connections will go through the TLS acceptor first and then further I/O /// will go through the negotiated TLS stream through the `protocol` /// specified. - pub fn new(protocol: T, acceptor: ServerConfig) -> Server { + pub fn new(protocol: T, acceptor: Arc) -> Server { Server { inner: Arc::new(protocol), - acceptor: Arc::new(acceptor), + acceptor: acceptor, } } } @@ -302,11 +302,11 @@ impl Client { /// The `connector` provided will be used to configure the TLS connection. Further I/O /// will go through the negotiated TLS stream through the `protocol` specified. pub fn new(protocol: T, - connector: ClientConfig, + connector: Arc, hostname: &str) -> Client { Client { inner: Arc::new(protocol), - connector: Arc::new(connector), + connector: connector, hostname: hostname.to_string(), } }