File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -37,15 +37,17 @@ where
3737
3838 fn make_tls_connect ( & mut self , hostname : & str ) -> io:: Result < RustlsConnect > {
3939 DNSNameRef :: try_from_ascii_str ( hostname)
40- . map ( |dns_name| RustlsConnect {
40+ . map ( |dns_name| RustlsConnect ( Some ( RustlsConnectData {
4141 hostname : dns_name. to_owned ( ) ,
4242 connector : Arc :: clone ( & self . config ) . into ( ) ,
43- } )
44- . map_err ( |_| io :: ErrorKind :: InvalidInput . into ( ) )
43+ } ) ) )
44+ . or ( Ok ( RustlsConnect ( None ) ) )
4545 }
4646}
4747
48- pub struct RustlsConnect {
48+ pub struct RustlsConnect ( Option < RustlsConnectData > ) ;
49+
50+ struct RustlsConnectData {
4951 hostname : DNSName ,
5052 connector : TlsConnector ,
5153}
@@ -59,10 +61,13 @@ where
5961 type Future = Pin < Box < dyn Future < Output = io:: Result < RustlsStream < S > > > + Send > > ;
6062
6163 fn connect ( self , stream : S ) -> Self :: Future {
62- self . connector
63- . connect ( self . hostname . as_ref ( ) , stream)
64- . map_ok ( |s| RustlsStream ( Box :: pin ( s) ) )
65- . boxed ( )
64+ match self . 0 {
65+ None => Box :: pin ( core:: future:: ready ( Err ( io:: ErrorKind :: InvalidInput . into ( ) ) ) ) ,
66+ Some ( c) => c. connector
67+ . connect ( c. hostname . as_ref ( ) , stream)
68+ . map_ok ( |s| RustlsStream ( Box :: pin ( s) ) )
69+ . boxed ( )
70+ }
6671 }
6772}
6873
You can’t perform that action at this time.
0 commit comments