use std::fmt::Debug;
use std::io::{Read, Write};
use std::net::TcpStream;
#[cfg(feature = "native-tls")]
mod native_tls;
#[cfg(feature = "native-tls")]
pub use self::native_tls::{NativeTlsConnector, NativeTlsStream};
#[cfg(any(feature = "rustls-aws-lc-rs", feature = "rustls-ring"))]
mod rustls;
#[cfg(any(feature = "rustls-aws-lc-rs", feature = "rustls-ring"))]
pub use self::rustls::{RustlsConnector, RustlsStream};
#[cfg(feature = "secure")]
pub trait TlsConnector: Debug {
type Stream: TlsStream;
fn connect(&self, domain: &str, stream: TcpStream) -> crate::FtpResult<Self::Stream>;
}
pub trait TlsStream: Debug {
type InnerStream: Read + Write;
fn tcp_stream(self) -> TcpStream;
fn get_ref(&self) -> &TcpStream;
fn mut_ref(&mut self) -> &mut Self::InnerStream;
}
#[derive(Debug)]
pub struct NoTlsStream;
impl TlsStream for NoTlsStream {
type InnerStream = TcpStream;
fn tcp_stream(self) -> TcpStream {
unimplemented!("NoTlsStream has no underlying TcpStream")
}
fn get_ref(&self) -> &TcpStream {
unimplemented!("NoTlsStream has no underlying TcpStream")
}
fn mut_ref(&mut self) -> &mut Self::InnerStream {
unimplemented!("NoTlsStream has no underlying TcpStream")
}
}