[Changed] proto {Server,Client}::new use Arc

This commit is contained in:
quininer kel 2017-03-01 10:34:24 +08:00
parent 1921f2bf49
commit 0db05aa9bf
3 changed files with 10 additions and 8 deletions

View File

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

View File

@ -94,7 +94,7 @@ impl<S, C> Future for MidHandshake<S, C>
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
loop { loop {
let stream = self.inner.as_mut().unwrap_or_else(|| unreachable!()); let stream = self.inner.as_mut().unwrap();
if !stream.session.is_handshaking() { break }; if !stream.session.is_handshaking() { break };
match stream.do_io() { match stream.do_io() {
@ -111,7 +111,7 @@ impl<S, C> Future for MidHandshake<S, C>
} }
} }
Ok(Async::Ready(self.inner.take().unwrap_or_else(|| unreachable!()))) Ok(Async::Ready(self.inner.take().unwrap()))
} }
} }
@ -228,4 +228,6 @@ 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 {
// TODO impl poll_{read, write}
}

View File

@ -41,10 +41,10 @@ impl<T> Server<T> {
/// connections will go through the TLS acceptor first and then further I/O /// connections will go through the TLS acceptor first and then further I/O
/// will go through the negotiated TLS stream through the `protocol` /// will go through the negotiated TLS stream through the `protocol`
/// specified. /// specified.
pub fn new(protocol: T, acceptor: ServerConfig) -> Server<T> { pub fn new(protocol: T, acceptor: Arc<ServerConfig>) -> Server<T> {
Server { Server {
inner: Arc::new(protocol), inner: Arc::new(protocol),
acceptor: Arc::new(acceptor), acceptor: acceptor,
} }
} }
} }
@ -302,11 +302,11 @@ impl<T> Client<T> {
/// The `connector` provided will be used to configure the TLS connection. Further I/O /// 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. /// will go through the negotiated TLS stream through the `protocol` specified.
pub fn new(protocol: T, pub fn new(protocol: T,
connector: ClientConfig, connector: Arc<ClientConfig>,
hostname: &str) -> Client<T> { hostname: &str) -> Client<T> {
Client { Client {
inner: Arc::new(protocol), inner: Arc::new(protocol),
connector: Arc::new(connector), connector: connector,
hostname: hostname.to_string(), hostname: hostname.to_string(),
} }
} }