rustls -> native_tls
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
use rustls;
|
||||
use std::io::Read;
|
||||
use std::io::Result;
|
||||
use std::io::Write;
|
||||
use std::net::TcpStream;
|
||||
use native_tls::TlsStream;
|
||||
|
||||
|
||||
pub enum Stream {
|
||||
Http(TcpStream),
|
||||
Https(rustls::ClientSession, TcpStream),
|
||||
Https(TlsStream<TcpStream>),
|
||||
Read(Box<Read>),
|
||||
#[cfg(test)] Test(Box<Read + Send>, Vec<u8>),
|
||||
}
|
||||
@@ -25,7 +26,7 @@ impl Read for Stream {
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
||||
match self {
|
||||
Stream::Http(sock) => sock.read(buf),
|
||||
Stream::Https(sess, sock) => rustls::Stream::new(sess, sock).read(buf),
|
||||
Stream::Https(stream) => stream.read(buf),
|
||||
Stream::Read(read) => read.read(buf),
|
||||
#[cfg(test)] Stream::Test(reader, _) => reader.read(buf),
|
||||
}
|
||||
@@ -36,7 +37,7 @@ impl Write for Stream {
|
||||
fn write(&mut self, buf: &[u8]) -> Result<usize> {
|
||||
match self {
|
||||
Stream::Http(sock) => sock.write(buf),
|
||||
Stream::Https(sess, sock) => rustls::Stream::new(sess, sock).write(buf),
|
||||
Stream::Https(stream) => stream.write(buf),
|
||||
Stream::Read(_) => panic!("Write to read stream"),
|
||||
#[cfg(test)] Stream::Test(_, writer) => writer.write(buf),
|
||||
}
|
||||
@@ -44,7 +45,7 @@ impl Write for Stream {
|
||||
fn flush(&mut self) -> Result<()> {
|
||||
match self {
|
||||
Stream::Http(sock) => sock.flush(),
|
||||
Stream::Https(sess, sock) => rustls::Stream::new(sess, sock).flush(),
|
||||
Stream::Https(stream) => stream.flush(),
|
||||
Stream::Read(_) => panic!("Flush read stream"),
|
||||
#[cfg(test)] Stream::Test(_, writer) => writer.flush(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user