Skip to content

Commit 6a775e1

Browse files
committed
Warn on unreachable_pub
1 parent 8092a89 commit 6a775e1

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

src/common/mod.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod handshake;
1010
pub(crate) use handshake::{IoSession, MidHandshake};
1111

1212
#[derive(Debug)]
13-
pub enum TlsState {
13+
pub(crate) enum TlsState {
1414
#[cfg(feature = "early-data")]
1515
EarlyData(usize, Vec<u8>),
1616
Stream,
@@ -21,56 +21,56 @@ pub enum TlsState {
2121

2222
impl TlsState {
2323
#[inline]
24-
pub fn shutdown_read(&mut self) {
24+
pub(crate) fn shutdown_read(&mut self) {
2525
match *self {
2626
TlsState::WriteShutdown | TlsState::FullyShutdown => *self = TlsState::FullyShutdown,
2727
_ => *self = TlsState::ReadShutdown,
2828
}
2929
}
3030

3131
#[inline]
32-
pub fn shutdown_write(&mut self) {
32+
pub(crate) fn shutdown_write(&mut self) {
3333
match *self {
3434
TlsState::ReadShutdown | TlsState::FullyShutdown => *self = TlsState::FullyShutdown,
3535
_ => *self = TlsState::WriteShutdown,
3636
}
3737
}
3838

3939
#[inline]
40-
pub fn writeable(&self) -> bool {
40+
pub(crate) fn writeable(&self) -> bool {
4141
!matches!(*self, TlsState::WriteShutdown | TlsState::FullyShutdown)
4242
}
4343

4444
#[inline]
45-
pub fn readable(&self) -> bool {
45+
pub(crate) fn readable(&self) -> bool {
4646
!matches!(*self, TlsState::ReadShutdown | TlsState::FullyShutdown)
4747
}
4848

4949
#[inline]
5050
#[cfg(feature = "early-data")]
51-
pub fn is_early_data(&self) -> bool {
51+
pub(crate) fn is_early_data(&self) -> bool {
5252
matches!(self, TlsState::EarlyData(..))
5353
}
5454

5555
#[inline]
5656
#[cfg(not(feature = "early-data"))]
57-
pub const fn is_early_data(&self) -> bool {
57+
pub(crate) const fn is_early_data(&self) -> bool {
5858
false
5959
}
6060
}
6161

62-
pub struct Stream<'a, IO, C> {
63-
pub io: &'a mut IO,
64-
pub session: &'a mut C,
65-
pub eof: bool,
62+
pub(crate) struct Stream<'a, IO, C> {
63+
pub(crate) io: &'a mut IO,
64+
pub(crate) session: &'a mut C,
65+
pub(crate) eof: bool,
6666
}
6767

6868
impl<'a, IO: AsyncRead + AsyncWrite + Unpin, C, SD> Stream<'a, IO, C>
6969
where
7070
C: DerefMut + Deref<Target = ConnectionCommon<SD>>,
7171
SD: SideData,
7272
{
73-
pub fn new(io: &'a mut IO, session: &'a mut C) -> Self {
73+
pub(crate) fn new(io: &'a mut IO, session: &'a mut C) -> Self {
7474
Stream {
7575
io,
7676
session,
@@ -80,16 +80,16 @@ where
8080
}
8181
}
8282

83-
pub fn set_eof(mut self, eof: bool) -> Self {
83+
pub(crate) fn set_eof(mut self, eof: bool) -> Self {
8484
self.eof = eof;
8585
self
8686
}
8787

88-
pub fn as_mut_pin(&mut self) -> Pin<&mut Self> {
88+
pub(crate) fn as_mut_pin(&mut self) -> Pin<&mut Self> {
8989
Pin::new(self)
9090
}
9191

92-
pub fn read_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
92+
pub(crate) fn read_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
9393
let mut reader = SyncReadAdapter { io: self.io, cx };
9494

9595
let n = match self.session.read_tls(&mut reader) {
@@ -110,7 +110,7 @@ where
110110
Poll::Ready(Ok(n))
111111
}
112112

113-
pub fn write_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
113+
pub(crate) fn write_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
114114
let mut writer = SyncWriteAdapter { io: self.io, cx };
115115

116116
match self.session.write_tls(&mut writer) {
@@ -119,7 +119,7 @@ where
119119
}
120120
}
121121

122-
pub fn handshake(&mut self, cx: &mut Context) -> Poll<io::Result<(usize, usize)>> {
122+
pub(crate) fn handshake(&mut self, cx: &mut Context) -> Poll<io::Result<(usize, usize)>> {
123123
let mut wrlen = 0;
124124
let mut rdlen = 0;
125125

@@ -372,9 +372,9 @@ where
372372
/// associated [`Context`].
373373
///
374374
/// Turns `Poll::Pending` into `WouldBlock`.
375-
pub struct SyncReadAdapter<'a, 'b, T> {
376-
pub io: &'a mut T,
377-
pub cx: &'a mut Context<'b>,
375+
pub(crate) struct SyncReadAdapter<'a, 'b, T> {
376+
pub(crate) io: &'a mut T,
377+
pub(crate) cx: &'a mut Context<'b>,
378378
}
379379

380380
impl<T: AsyncRead + Unpin> Read for SyncReadAdapter<'_, '_, T> {
@@ -393,9 +393,9 @@ impl<T: AsyncRead + Unpin> Read for SyncReadAdapter<'_, '_, T> {
393393
/// associated [`Context`].
394394
///
395395
/// Turns `Poll::Pending` into `WouldBlock`.
396-
pub struct SyncWriteAdapter<'a, 'b, T> {
397-
pub io: &'a mut T,
398-
pub cx: &'a mut Context<'b>,
396+
pub(crate) struct SyncWriteAdapter<'a, 'b, T> {
397+
pub(crate) io: &'a mut T,
398+
pub(crate) cx: &'a mut Context<'b>,
399399
}
400400

401401
impl<T: Unpin> SyncWriteAdapter<'_, '_, T> {

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
//!
3737
//! see <https://github.com/tokio-rs/tls/issues/41>
3838
39+
#![warn(unreachable_pub)]
40+
3941
use std::future::Future;
4042
use std::io;
4143
#[cfg(unix)]

tests/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod utils {
88
use tokio::io::{self, AsyncWrite, AsyncWriteExt};
99

1010
#[allow(dead_code)]
11-
pub fn make_configs() -> (ServerConfig, ClientConfig) {
11+
pub(crate) fn make_configs() -> (ServerConfig, ClientConfig) {
1212
// A test root certificate that is the trust anchor for the CHAIN.
1313
const ROOT: &str = include_str!("certs/root.pem");
1414
// A server certificate chain that includes both an end-entity server certificate
@@ -40,7 +40,7 @@ mod utils {
4040
}
4141

4242
#[allow(dead_code)]
43-
pub async fn write<W: AsyncWrite + Unpin>(
43+
pub(crate) async fn write<W: AsyncWrite + Unpin>(
4444
w: &mut W,
4545
data: &[u8],
4646
vectored: bool,
@@ -65,5 +65,5 @@ mod utils {
6565
}
6666

6767
#[allow(dead_code)]
68-
pub const TEST_SERVER_DOMAIN: &str = "foobar.com";
68+
pub(crate) const TEST_SERVER_DOMAIN: &str = "foobar.com";
6969
}

0 commit comments

Comments
 (0)