Rename trait HttpsStream -> ReadWrite and make it public
Also provide an example of how to use it.
This commit is contained in:
10
src/ntls.rs
10
src/ntls.rs
@@ -1,6 +1,6 @@
|
||||
use crate::error::Error;
|
||||
use crate::error::ErrorKind;
|
||||
use crate::stream::{HttpsStream, TlsConnector};
|
||||
use crate::stream::{ReadWrite, TlsConnector};
|
||||
|
||||
use std::net::TcpStream;
|
||||
use std::sync::Arc;
|
||||
@@ -11,11 +11,7 @@ pub(crate) fn default_tls_config() -> std::sync::Arc<dyn TlsConnector> {
|
||||
}
|
||||
|
||||
impl TlsConnector for native_tls::TlsConnector {
|
||||
fn connect(
|
||||
&self,
|
||||
dns_name: &str,
|
||||
tcp_stream: TcpStream,
|
||||
) -> Result<Box<dyn HttpsStream>, Error> {
|
||||
fn connect(&self, dns_name: &str, tcp_stream: TcpStream) -> Result<Box<dyn ReadWrite>, Error> {
|
||||
let stream =
|
||||
native_tls::TlsConnector::connect(self, dns_name, tcp_stream).map_err(|e| {
|
||||
ErrorKind::ConnectionFailed
|
||||
@@ -28,7 +24,7 @@ impl TlsConnector for native_tls::TlsConnector {
|
||||
}
|
||||
|
||||
#[cfg(feature = "native-tls")]
|
||||
impl HttpsStream for native_tls::TlsStream<TcpStream> {
|
||||
impl ReadWrite for native_tls::TlsStream<TcpStream> {
|
||||
fn socket(&self) -> Option<&TcpStream> {
|
||||
Some(self.get_ref())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user