This repository was archived by the owner on Jan 14, 2025. It is now read-only.
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
37
37
38
38
fn make_tls_connect ( & mut self , hostname : & str ) -> io:: Result < RustlsConnect > {
39
39
DNSNameRef :: try_from_ascii_str ( hostname)
40
- . map ( |dns_name| RustlsConnect {
40
+ . map ( |dns_name| RustlsConnect ( Some ( RustlsConnectData {
41
41
hostname : dns_name. to_owned ( ) ,
42
42
connector : Arc :: clone ( & self . config ) . into ( ) ,
43
- } )
44
- . map_err ( |_| io :: ErrorKind :: InvalidInput . into ( ) )
43
+ } ) ) )
44
+ . or ( Ok ( RustlsConnect ( None ) ) )
45
45
}
46
46
}
47
47
48
- pub struct RustlsConnect {
48
+ pub struct RustlsConnect ( Option < RustlsConnectData > ) ;
49
+
50
+ struct RustlsConnectData {
49
51
hostname : DNSName ,
50
52
connector : TlsConnector ,
51
53
}
@@ -59,10 +61,13 @@ where
59
61
type Future = Pin < Box < dyn Future < Output = io:: Result < RustlsStream < S > > > + Send > > ;
60
62
61
63
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
+ }
66
71
}
67
72
}
68
73
You can’t perform that action at this time.
0 commit comments