From 98e7a2fbf4781f1b92c854a919ea075afe83899f Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 5 Jun 2017 00:45:16 +0200 Subject: [PATCH] starttls: parameterize TcpStream --- src/starttls.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/starttls.rs b/src/starttls.rs index b14982a..59946da 100644 --- a/src/starttls.rs +++ b/src/starttls.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use futures::{Future, Sink, Poll, Async}; use futures::stream::Stream; use futures::sink; -use tokio_core::net::TcpStream; +use tokio_io::{AsyncRead, AsyncWrite}; use rustls::*; use tokio_rustls::*; use xml; @@ -15,22 +15,22 @@ use super::{XMPPStream, XMPPCodec, Packet}; const NS_XMPP_STREAM: &str = "http://etherx.jabber.org/streams"; const NS_XMPP_TLS: &str = "urn:ietf:params:xml:ns:xmpp-tls"; -pub struct StartTlsClient { - state: StartTlsClientState, +pub struct StartTlsClient { + state: StartTlsClientState, arc_config: Arc, } -enum StartTlsClientState { +enum StartTlsClientState { Invalid, - AwaitFeatures(XMPPStream), - SendStartTls(sink::Send>), - AwaitProceed(XMPPStream), - StartingTls(ConnectAsync), + AwaitFeatures(XMPPStream), + SendStartTls(sink::Send>), + AwaitProceed(XMPPStream), + StartingTls(ConnectAsync), } -impl StartTlsClient { +impl StartTlsClient { /// Waits for - pub fn from_stream(xmpp_stream: XMPPStream, arc_config: Arc) -> Self { + pub fn from_stream(xmpp_stream: XMPPStream, arc_config: Arc) -> Self { StartTlsClient { state: StartTlsClientState::AwaitFeatures(xmpp_stream), arc_config: arc_config, @@ -39,8 +39,8 @@ impl StartTlsClient { } // TODO: eval , check ns -impl Future for StartTlsClient { - type Item = XMPPStream>; +impl Future for StartTlsClient { + type Item = XMPPStream>; type Error = Error; fn poll(&mut self) -> Poll {