Skip to content

Commit e86fe1b

Browse files
docs: expand documentation to most types
1 parent 06a8fc9 commit e86fe1b

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

src/ip_version.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
use std::{
2-
fmt::Display,
32
hash::Hash,
43
net::{Ipv4Addr, Ipv6Addr},
54
};
65

7-
pub trait IpVersion:
8-
Copy + Sized + Hash + Eq + Unpin + Send + Sync + Display + 'static + private::Sealed
9-
{
10-
}
6+
/// Either an [`Ipv4Addr`] or an [`Ipv6Addr`].
7+
pub trait IpVersion: Copy + Hash + Eq + Unpin + Send + Sync + 'static + private::Sealed {}
118

129
impl IpVersion for Ipv4Addr {}
1310
impl IpVersion for Ipv6Addr {}

src/packet.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! ICMP packets implementation used by [`raw_pinger`].
2+
//!
3+
//! [`raw_pinger`]: crate::raw_pinger
4+
15
use std::{borrow::Cow, marker::PhantomData};
26

37
use pnet_packet::{

src/raw_pinger/blocking.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{
1313
IpVersion,
1414
};
1515

16+
/// Synchronous pinger
1617
pub struct RawBlockingPinger<V: IpVersion> {
1718
socket: BaseSocket,
1819
_version: PhantomData<V>,
@@ -28,11 +29,13 @@ impl<V: IpVersion> RawBlockingPinger<V> {
2829
})
2930
}
3031

32+
/// Send a ICMP ECHO request packet
3133
pub fn send_to(&self, addr: V, packet: &EchoRequestPacket<V>) -> io::Result<()> {
3234
let addr = addr.to_socket_addr();
3335
self.socket.send_to(packet.as_bytes(), addr).map(|_sent| ())
3436
}
3537

38+
/// Receive an ICMP ECHO reply packet
3639
pub fn recv(&self, buf: &mut [MaybeUninit<u8>]) -> io::Result<Option<EchoReplyPacket<'_, V>>> {
3740
let (received, source) = match self.socket.recv(buf) {
3841
Ok((received, source)) => (received, source),

src/raw_pinger/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Synchronous and asynchronous raw pinger implementation
2+
13
use std::{
24
borrow::Cow,
35
future::Future,
@@ -23,6 +25,7 @@ pub type RawV6Pinger = RawPinger<Ipv6Addr>;
2325

2426
mod blocking;
2527

28+
/// Asynchronous pinger
2629
pub struct RawPinger<V: IpVersion> {
2730
socket: Socket,
2831
_version: PhantomData<V>,
@@ -38,6 +41,7 @@ impl<V: IpVersion> RawPinger<V> {
3841
})
3942
}
4043

44+
/// Send a ICMP ECHO request packet
4145
pub fn send_to<'a>(&'a self, addr: V, packet: &'a EchoRequestPacket<V>) -> SendFuture<'a, V> {
4246
SendFuture {
4347
pinger: self,
@@ -46,6 +50,7 @@ impl<V: IpVersion> RawPinger<V> {
4650
}
4751
}
4852

53+
/// Send a ICMP ECHO request packet
4954
pub fn poll_send_to(
5055
&self,
5156
cx: &mut Context<'_>,
@@ -58,13 +63,15 @@ impl<V: IpVersion> RawPinger<V> {
5863
Poll::Ready(result.map(|_sent| ()))
5964
}
6065

66+
/// Receive an ICMP ECHO reply packet
6167
pub fn recv(&self) -> RecvFuture<'_, V> {
6268
RecvFuture {
6369
pinger: self,
6470
buf: Vec::with_capacity(1600),
6571
}
6672
}
6773

74+
/// Receive an ICMP ECHO reply packet
6875
pub fn poll_recv(
6976
&self,
7077
cx: &mut Context<'_>,
@@ -87,6 +94,7 @@ impl<V: IpVersion> RawPinger<V> {
8794
}
8895
}
8996

97+
/// [`Future`] obtained from [`RawPinger::send_to`].
9098
pub struct SendFuture<'a, V: IpVersion> {
9199
pinger: &'a RawPinger<V>,
92100
addr: V,
@@ -101,6 +109,7 @@ impl<'a, V: IpVersion> Future for SendFuture<'a, V> {
101109
}
102110
}
103111

112+
/// [`Future`] obtained from [`RawPinger::recv`].
104113
pub struct RecvFuture<'a, V: IpVersion> {
105114
pinger: &'a RawPinger<V>,
106115
buf: Vec<u8>,

0 commit comments

Comments
 (0)