Skip to content

Commit d7c602a

Browse files
style: deny unreachable_pub
1 parent 00f1175 commit d7c602a

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/instant.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ use std::{
44
};
55

66
#[derive(Debug, Clone)]
7-
pub struct ReferenceInstant {
7+
pub(crate) struct ReferenceInstant {
88
#[cfg(not(feature = "strong"))]
99
instant: Instant,
1010
}
1111

1212
#[derive(Debug, Copy, Clone)]
13-
pub struct RelativeInstant {
13+
pub(crate) struct RelativeInstant {
1414
#[cfg(feature = "strong")]
1515
relative: Instant,
1616
#[cfg(not(feature = "strong"))]
1717
relative: Duration,
1818
}
1919

2020
impl ReferenceInstant {
21-
pub fn new() -> Self {
21+
pub(crate) fn new() -> Self {
2222
Self {
2323
#[cfg(not(feature = "strong"))]
2424
instant: Instant::now(),
2525
}
2626
}
2727

28-
pub fn now(&self) -> RelativeInstant {
28+
pub(crate) fn now(&self) -> RelativeInstant {
2929
RelativeInstant {
3030
#[cfg(feature = "strong")]
3131
relative: Instant::now(),
@@ -37,10 +37,10 @@ impl ReferenceInstant {
3737

3838
impl RelativeInstant {
3939
#[cfg(not(feature = "strong"))]
40-
pub const ENCODED_LEN: usize = 12;
40+
pub(crate) const ENCODED_LEN: usize = 12;
4141

4242
#[cfg(not(feature = "strong"))]
43-
pub fn encode(&self) -> [u8; Self::ENCODED_LEN] {
43+
pub(crate) fn encode(&self) -> [u8; Self::ENCODED_LEN] {
4444
let mut buf = [0u8; Self::ENCODED_LEN];
4545
let (secs, nanos) = buf.split_at_mut(8);
4646
secs.copy_from_slice(&self.relative.as_secs().to_ne_bytes());
@@ -50,7 +50,7 @@ impl RelativeInstant {
5050
}
5151

5252
#[cfg(not(feature = "strong"))]
53-
pub fn decode(buf: &[u8; Self::ENCODED_LEN]) -> Option<Self> {
53+
pub(crate) fn decode(buf: &[u8; Self::ENCODED_LEN]) -> Option<Self> {
5454
let (secs, nanos) = buf.split_at(8);
5555
let secs = u64::from_ne_bytes(secs.try_into().unwrap());
5656
let nanos = u32::from_ne_bytes(nanos.try_into().unwrap());

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
2525
#![deny(
2626
rust_2018_idioms,
27+
unreachable_pub,
2728
clippy::doc_markdown,
2829
rustdoc::broken_intra_doc_links
2930
)]

src/socket/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use socket2::{Domain, Protocol, SockAddr, Type};
1111

1212
use crate::IpVersion;
1313

14-
pub struct BaseSocket {
14+
pub(crate) struct BaseSocket {
1515
socket: socket2::Socket,
1616
}
1717

1818
impl BaseSocket {
19-
pub fn new_icmp<V: IpVersion>(
19+
pub(crate) fn new_icmp<V: IpVersion>(
2020
blocking: bool,
2121
read_timeout: Option<Duration>,
2222
) -> io::Result<Self> {
@@ -43,7 +43,7 @@ impl BaseSocket {
4343
socket2::Socket::new(Domain::IPV6, Type::RAW, Some(Protocol::ICMPV6))
4444
}
4545

46-
pub fn recv(&self, buf: &mut [MaybeUninit<u8>]) -> io::Result<(&'_ [u8], SocketAddr)> {
46+
pub(crate) fn recv(&self, buf: &mut [MaybeUninit<u8>]) -> io::Result<(&'_ [u8], SocketAddr)> {
4747
self.socket.recv_from(buf).map(|(filled, source)| {
4848
(
4949
unsafe { slice::from_raw_parts(buf.as_ptr().cast::<u8>(), filled) },
@@ -52,7 +52,7 @@ impl BaseSocket {
5252
})
5353
}
5454

55-
pub fn send_to(&self, buf: &[u8], addr: SocketAddr) -> io::Result<usize> {
55+
pub(crate) fn send_to(&self, buf: &[u8], addr: SocketAddr) -> io::Result<usize> {
5656
let addr = SockAddr::from(addr);
5757

5858
self.socket.send_to(buf, &addr)

src/socket/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ use std::{
77

88
use tokio::io::unix::AsyncFd;
99

10-
pub use self::base::BaseSocket;
10+
pub(crate) use self::base::BaseSocket;
1111
use crate::IpVersion;
1212

1313
mod base;
1414

15-
pub struct Socket {
15+
pub(crate) struct Socket {
1616
fd: AsyncFd<BaseSocket>,
1717
}
1818

1919
impl Socket {
20-
pub fn new_icmp<V: IpVersion>() -> io::Result<Self> {
20+
pub(crate) fn new_icmp<V: IpVersion>() -> io::Result<Self> {
2121
let base = BaseSocket::new_icmp::<V>(false, None)?;
2222

2323
let fd = AsyncFd::new(base)?;
2424
Ok(Self { fd })
2525
}
2626

27-
pub fn poll_read(
27+
pub(crate) fn poll_read(
2828
&self,
2929
cx: &mut Context<'_>,
3030
buf: &mut [MaybeUninit<u8>],
@@ -40,7 +40,7 @@ impl Socket {
4040
}
4141
}
4242

43-
pub fn poll_write_to(
43+
pub(crate) fn poll_write_to(
4444
&self,
4545
cx: &mut Context<'_>,
4646
buf: &[u8],

0 commit comments

Comments
 (0)