@@ -38,21 +38,19 @@ where
3838{
3939 type Stream = RustlsStream < S > ;
4040 type TlsConnect = RustlsConnect ;
41- type Error = io :: Error ;
41+ type Error = rustls :: pki_types :: InvalidDnsNameError ;
4242
43- fn make_tls_connect ( & mut self , hostname : & str ) -> io:: Result < RustlsConnect > {
44- ServerName :: try_from ( hostname)
45- . map ( |dns_name| {
46- RustlsConnect ( Some ( RustlsConnectData {
47- hostname : dns_name. to_owned ( ) ,
48- connector : Arc :: clone ( & self . config ) . into ( ) ,
49- } ) )
43+ fn make_tls_connect ( & mut self , hostname : & str ) -> Result < RustlsConnect , Self :: Error > {
44+ ServerName :: try_from ( hostname) . map ( |dns_name| {
45+ RustlsConnect ( RustlsConnectData {
46+ hostname : dns_name. to_owned ( ) ,
47+ connector : Arc :: clone ( & self . config ) . into ( ) ,
5048 } )
51- . or ( Ok ( RustlsConnect ( None ) ) )
49+ } )
5250 }
5351}
5452
55- pub struct RustlsConnect ( Option < RustlsConnectData > ) ;
53+ pub struct RustlsConnect ( RustlsConnectData ) ;
5654
5755struct RustlsConnectData {
5856 hostname : ServerName < ' static > ,
@@ -68,15 +66,13 @@ where
6866 type Future = Pin < Box < dyn Future < Output = io:: Result < RustlsStream < S > > > + Send > > ;
6967
7068 fn connect ( self , stream : S ) -> Self :: Future {
71- match self . 0 {
72- None => Box :: pin ( core:: future:: ready ( Err ( io:: ErrorKind :: InvalidInput . into ( ) ) ) ) ,
73- Some ( c) => Box :: pin ( async move {
74- c. connector
75- . connect ( c. hostname , stream)
76- . await
77- . map ( |s| RustlsStream ( Box :: pin ( s) ) )
78- } ) ,
79- }
69+ Box :: pin ( async move {
70+ self . 0
71+ . connector
72+ . connect ( self . 0 . hostname , stream)
73+ . await
74+ . map ( |s| RustlsStream ( Box :: pin ( s) ) )
75+ } )
8076 }
8177}
8278
0 commit comments