@@ -4,15 +4,6 @@ use std::ops::{Deref, DerefMut};
4
4
use std:: pin:: Pin ;
5
5
use std:: str;
6
6
7
- #[ cfg( feature = "async-native-tls" ) ]
8
- use async_native_tls:: { TlsConnector , TlsStream } ;
9
-
10
- #[ cfg( all( feature = "async-native-tls" , feature = "runtime-tokio" ) ) ]
11
- use tokio:: net:: { TcpStream , ToSocketAddrs } ;
12
-
13
- #[ cfg( all( feature = "async-native-tls" , feature = "runtime-async-std" ) ) ]
14
- use async_std:: net:: { TcpStream , ToSocketAddrs } ;
15
-
16
7
use async_channel:: { self as channel, bounded} ;
17
8
#[ cfg( feature = "runtime-async-std" ) ]
18
9
use async_std:: io:: { Read , Write , WriteExt } ;
@@ -118,68 +109,6 @@ impl<T: Read + Write + Unpin + fmt::Debug> DerefMut for Session<T> {
118
109
}
119
110
}
120
111
121
- /// Connect to a server using a TLS-encrypted connection.
122
- ///
123
- /// The returned [`Client`] is unauthenticated; to access session-related methods (through
124
- /// [`Session`]), use [`Client::login`] or [`Client::authenticate`].
125
- ///
126
- /// The domain must be passed in separately from the `TlsConnector` so that the certificate of the
127
- /// IMAP server can be validated.
128
- ///
129
- /// # Examples
130
- ///
131
- /// ```no_run
132
- /// # fn main() -> async_imap::error::Result<()> {
133
- /// # async_std::task::block_on(async {
134
- ///
135
- /// let tls = async_native_tls::TlsConnector::new();
136
- /// let client = async_imap::connect(("imap.example.org", 993), "imap.example.org", tls).await?;
137
- ///
138
- /// # Ok(())
139
- /// # }) }
140
- /// ```
141
- #[ cfg( feature = "async-native-tls" ) ]
142
- pub async fn connect < A : ToSocketAddrs , S : AsRef < str > > (
143
- addr : A ,
144
- domain : S ,
145
- ssl_connector : TlsConnector ,
146
- ) -> Result < Client < TlsStream < TcpStream > > > {
147
- let stream = TcpStream :: connect ( addr) . await ?;
148
- let ssl_stream = ssl_connector. connect ( domain. as_ref ( ) , stream) . await ?;
149
-
150
- let mut client = Client :: new ( ssl_stream) ;
151
- let _greeting = match client. read_response ( ) . await {
152
- Some ( greeting) => greeting,
153
- None => {
154
- return Err ( Error :: Bad (
155
- "could not read server Greeting after connect" . into ( ) ,
156
- ) ) ;
157
- }
158
- } ;
159
-
160
- Ok ( client)
161
- }
162
-
163
- impl < T : Read + Write + Unpin + fmt:: Debug + Send > Client < T > {
164
- /// This will upgrade an IMAP client from using a regular TCP connection to use TLS.
165
- ///
166
- /// The domain parameter is required to perform hostname verification.
167
- #[ cfg( feature = "async-native-tls" ) ]
168
- pub async fn secure < S : AsRef < str > > (
169
- mut self ,
170
- domain : S ,
171
- ssl_connector : TlsConnector ,
172
- ) -> Result < Client < TlsStream < T > > > {
173
- self . run_command_and_check_ok ( "STARTTLS" , None ) . await ?;
174
- let ssl_stream = ssl_connector
175
- . connect ( domain. as_ref ( ) , self . conn . stream . into_inner ( ) )
176
- . await ?;
177
-
178
- let client = Client :: new ( ssl_stream) ;
179
- Ok ( client)
180
- }
181
- }
182
-
183
112
// As the pattern of returning the unauthenticated `Client` (a.k.a. `self`) back with a login error
184
113
// is relatively common, it's abstacted away into a macro here.
185
114
//
0 commit comments