|
10 | 10 | T: MakeTlsMode<Socket>, |
11 | 11 | { |
12 | 12 | #[state_machine_future(start, transitions(MakingTlsMode))] |
13 | | - Start { make_tls_mode: T, config: Builder }, |
| 13 | + Start { |
| 14 | + make_tls_mode: T, |
| 15 | + config: Result<Builder, Error>, |
| 16 | + }, |
14 | 17 | #[state_machine_future(transitions(Connecting))] |
15 | 18 | MakingTlsMode { |
16 | 19 | future: T::Future, |
@@ -38,15 +41,17 @@ where |
38 | 41 | fn poll_start<'a>(state: &'a mut RentToOwn<'a, Start<T>>) -> Poll<AfterStart<T>, Error> { |
39 | 42 | let mut state = state.take(); |
40 | 43 |
|
41 | | - if state.config.0.host.is_empty() { |
| 44 | + let config = state.config?; |
| 45 | + |
| 46 | + if config.0.host.is_empty() { |
42 | 47 | return Err(Error::missing_host()); |
43 | 48 | } |
44 | 49 |
|
45 | | - if state.config.0.port.len() > 1 && state.config.0.port.len() != state.config.0.host.len() { |
| 50 | + if config.0.port.len() > 1 && config.0.port.len() != config.0.host.len() { |
46 | 51 | return Err(Error::invalid_port_count()); |
47 | 52 | } |
48 | 53 |
|
49 | | - let hostname = match &state.config.0.host[0] { |
| 54 | + let hostname = match &config.0.host[0] { |
50 | 55 | Host::Tcp(host) => &**host, |
51 | 56 | // postgres doesn't support TLS over unix sockets, so the choice here doesn't matter |
52 | 57 | #[cfg(unix)] |
|
58 | 63 | future, |
59 | 64 | idx: 0, |
60 | 65 | make_tls_mode: state.make_tls_mode, |
61 | | - config: state.config, |
| 66 | + config, |
62 | 67 | }) |
63 | 68 | } |
64 | 69 |
|
@@ -113,7 +118,7 @@ impl<T> ConnectFuture<T> |
113 | 118 | where |
114 | 119 | T: MakeTlsMode<Socket>, |
115 | 120 | { |
116 | | - pub fn new(make_tls_mode: T, config: Builder) -> ConnectFuture<T> { |
| 121 | + pub fn new(make_tls_mode: T, config: Result<Builder, Error>) -> ConnectFuture<T> { |
117 | 122 | Connect::start(make_tls_mode, config) |
118 | 123 | } |
119 | 124 | } |
0 commit comments