|
2 | 2 |
|
3 | 3 | use std::io::{self, Read, Write};
|
4 | 4 | use std::net::{SocketAddr, TcpListener};
|
5 |
| -use std::pin::Pin; |
6 | 5 | use std::sync::Arc;
|
7 |
| -use std::task::{Context, Poll}; |
8 | 6 | use std::thread;
|
9 | 7 |
|
10 |
| -use futures_util::{future::Future, ready}; |
11 | 8 | use rustls::pki_types::ServerName;
|
12 | 9 | use rustls::{self, ClientConfig, ServerConnection, Stream};
|
13 |
| -use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}; |
| 10 | +use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; |
14 | 11 | use tokio::net::TcpStream;
|
15 | 12 | use tokio_rustls::client::TlsStream;
|
16 | 13 | use tokio_rustls::TlsConnector;
|
17 | 14 |
|
18 |
| -struct Read1<T>(T); |
19 |
| - |
20 |
| -impl<T: AsyncRead + Unpin> Future for Read1<T> { |
21 |
| - type Output = io::Result<()>; |
22 |
| - |
23 |
| - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
24 |
| - let mut buf = [0]; |
25 |
| - let mut buf = ReadBuf::new(&mut buf); |
26 |
| - |
27 |
| - ready!(Pin::new(&mut self.0).poll_read(cx, &mut buf))?; |
28 |
| - |
29 |
| - if buf.filled().is_empty() { |
30 |
| - Poll::Ready(Ok(())) |
31 |
| - } else { |
32 |
| - cx.waker().wake_by_ref(); |
33 |
| - Poll::Pending |
34 |
| - } |
35 |
| - } |
36 |
| -} |
37 |
| - |
38 | 15 | async fn send<S: AsyncRead + AsyncWrite + Unpin>(
|
39 | 16 | config: Arc<ClientConfig>,
|
40 | 17 | addr: SocketAddr,
|
|
0 commit comments