Skip to content

Commit a70ea6c

Browse files
committed
Clean up library imports
1 parent 79acfd6 commit a70ea6c

File tree

6 files changed

+45
-29
lines changed

6 files changed

+45
-29
lines changed

src/client.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
use super::*;
2-
use crate::common::IoSession;
1+
use std::io;
32
#[cfg(unix)]
43
use std::os::unix::io::{AsRawFd, RawFd};
54
#[cfg(windows)]
65
use std::os::windows::io::{AsRawSocket, RawSocket};
6+
use std::pin::Pin;
7+
use std::task::{Context, Poll};
8+
9+
use rustls::ClientConnection;
10+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
11+
12+
use crate::common::{IoSession, Stream, TlsState};
713

814
/// A wrapper around an underlying raw stream which implements the TLS or SSL
915
/// protocol.

src/common/handshake.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
use crate::common::{Stream, TlsState};
2-
use rustls::{ConnectionCommon, SideData};
31
use std::future::Future;
42
use std::ops::{Deref, DerefMut};
53
use std::pin::Pin;
64
use std::task::{Context, Poll};
75
use std::{io, mem};
6+
7+
use rustls::{ConnectionCommon, SideData};
88
use tokio::io::{AsyncRead, AsyncWrite};
99

10+
use crate::common::{Stream, TlsState};
11+
1012
pub(crate) trait IoSession {
1113
type Io;
1214
type Session;

src/common/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
mod handshake;
2-
3-
pub(crate) use handshake::{IoSession, MidHandshake};
4-
use rustls::{ConnectionCommon, SideData};
51
use std::io::{self, IoSlice, Read, Write};
62
use std::ops::{Deref, DerefMut};
73
use std::pin::Pin;
84
use std::task::{Context, Poll};
5+
6+
use rustls::{ConnectionCommon, SideData};
97
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
108

9+
mod handshake;
10+
pub(crate) use handshake::{IoSession, MidHandshake};
11+
1112
#[derive(Debug)]
1213
pub enum TlsState {
1314
#[cfg(feature = "early-data")]

src/common/test_stream.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
use super::Stream;
2-
use futures_util::future::poll_fn;
3-
use futures_util::task::noop_waker_ref;
4-
use rustls::{ClientConnection, Connection, ServerConnection};
51
use std::io::{self, Cursor, Read, Write};
62
use std::pin::Pin;
73
use std::task::{Context, Poll};
4+
5+
use futures_util::future::poll_fn;
6+
use futures_util::task::noop_waker_ref;
7+
use rustls::{ClientConnection, Connection, ServerConnection};
88
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf};
99

10+
use super::Stream;
11+
1012
struct Good<'a>(&'a mut Connection);
1113

1214
impl<'a> AsyncRead for Good<'a> {

src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@
3636
//!
3737
//! see <https://github.com/tokio-rs/tls/issues/41>
3838
39+
use std::future::Future;
40+
use std::io;
41+
#[cfg(unix)]
42+
use std::os::unix::io::{AsRawFd, RawFd};
43+
#[cfg(windows)]
44+
use std::os::windows::io::{AsRawSocket, RawSocket};
45+
use std::pin::Pin;
46+
use std::sync::Arc;
47+
use std::task::{Context, Poll};
48+
49+
pub use rustls;
50+
use rustls::{ClientConfig, ClientConnection, CommonState, ServerConfig, ServerConnection};
51+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
52+
3953
macro_rules! ready {
4054
( $e:expr ) => {
4155
match $e {
@@ -47,23 +61,9 @@ macro_rules! ready {
4761

4862
pub mod client;
4963
mod common;
64+
use common::{MidHandshake, TlsState};
5065
pub mod server;
5166

52-
use common::{MidHandshake, Stream, TlsState};
53-
use rustls::{ClientConfig, ClientConnection, CommonState, ServerConfig, ServerConnection};
54-
use std::future::Future;
55-
use std::io;
56-
#[cfg(unix)]
57-
use std::os::unix::io::{AsRawFd, RawFd};
58-
#[cfg(windows)]
59-
use std::os::windows::io::{AsRawSocket, RawSocket};
60-
use std::pin::Pin;
61-
use std::sync::Arc;
62-
use std::task::{Context, Poll};
63-
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
64-
65-
pub use rustls;
66-
6767
/// A wrapper around a `rustls::ClientConfig`, providing an async `connect` method.
6868
#[derive(Clone)]
6969
pub struct TlsConnector {

src/server.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
use std::io;
12
#[cfg(unix)]
23
use std::os::unix::io::{AsRawFd, RawFd};
34
#[cfg(windows)]
45
use std::os::windows::io::{AsRawSocket, RawSocket};
6+
use std::pin::Pin;
7+
use std::task::{Context, Poll};
58

6-
use super::*;
7-
use crate::common::IoSession;
9+
use rustls::ServerConnection;
10+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
11+
12+
use crate::common::{IoSession, Stream, TlsState};
813

914
/// A wrapper around an underlying raw stream which implements the TLS or SSL
1015
/// protocol.

0 commit comments

Comments
 (0)