Merge pull request #48 from zargony/optional_tls_stream_type

Add `MaybeTlsStream` wrapper type for streams that might be protected with TLS
pull/1/head
Daniel Abramov 6 years ago committed by GitHub
commit 1dcf833f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/connect.rs
  2. 3
      src/lib.rs

@ -39,10 +39,12 @@ mod encryption {
use tungstenite::Error;
use tungstenite::stream::Mode;
use stream::NoDelay;
use stream::{NoDelay, Stream as StreamSwitcher};
pub use stream::Stream as StreamSwitcher;
pub type AutoStream<S> = StreamSwitcher<S, TlsStream<S>>;
/// A stream that might be protected with TLS.
pub type MaybeTlsStream<S> = StreamSwitcher<S, TlsStream<S>>;
pub type AutoStream<S> = MaybeTlsStream<S>;
impl<T: Read + Write + NoDelay> NoDelay for TlsStream<T> {
fn set_nodelay(&mut self, nodelay: bool) -> IoResult<()> {
@ -68,6 +70,9 @@ mod encryption {
}
}
#[cfg(feature="tls")]
pub use self::encryption::MaybeTlsStream;
#[cfg(not(feature="tls"))]
mod encryption {
use futures::{future, Future};

@ -45,6 +45,9 @@ use tungstenite::{
#[cfg(feature="connect")]
pub use connect::{connect_async, client_async_tls};
#[cfg(all(feature="connect", feature="tls"))]
pub use connect::MaybeTlsStream;
/// Creates a WebSocket handshake from a request and a stream.
/// For convenience, the user may call this with a url string, a URL,
/// or a `Request`. Calling with `Request` allows the user to add

Loading…
Cancel
Save