diff --git a/src/stream.rs b/src/stream.rs index 47fb3ad..3cf894d 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -38,6 +38,24 @@ impl fmt::Debug for MaybeHttpsStream { } } +impl From> for MaybeHttpsStream { + fn from(inner: native_tls::TlsStream) -> Self { + MaybeHttpsStream::Https(TlsStream::from(inner)) + } +} + +impl From for MaybeHttpsStream { + fn from(inner: T) -> Self { + MaybeHttpsStream::Http(inner) + } +} + +impl From> for MaybeHttpsStream { + fn from(inner: TlsStream) -> Self { + MaybeHttpsStream::Https(inner) + } +} + impl Read for MaybeHttpsStream { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { @@ -118,6 +136,12 @@ impl fmt::Debug for TlsStream { } } +impl From> for TlsStream { + fn from(stream: native_tls::TlsStream) -> Self { + TlsStream { inner: stream } + } +} + impl Read for TlsStream { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result {