1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! An ICMP echo ("ping") implementation for IPv4 and IPv6.
//!
//! Send an ICMP echo request to a target [`IpAddr`] and wait for the reply or
//! a timeout.
//!
//! # Quick start
//!
//! The main entry point is the [`Ping`] builder, created with [`new`].
//! Configure the options you need and call [`Ping::send`], which returns a
//! [`PingResult`] describing the reply.
//!
//! ```no_run
//! use std::time::Duration;
//!
//! let target = "8.8.8.8".parse().unwrap();
//! let result = ping::new(target)
//! .timeout(Duration::from_secs(2))
//! .ttl(64)
//! .send()
//! .expect("ping failed");
//!
//! println!("round-trip time: {:?}", result.rtt);
//! ```
//!
//! # Pinging a host name
//!
//! Only an [`IpAddr`] is accepted. To ping a host name, resolve it first with
//! [`ToSocketAddrs`](std::net::ToSocketAddrs).
//!
//! ```no_run
//! use std::net::ToSocketAddrs;
//!
//! // The port is irrelevant, we only need the resolved IP.
//! let addr = "www.google.com:0"
//! .to_socket_addrs()
//! .unwrap()
//! .next()
//! .unwrap()
//! .ip();
//!
//! ping::new(addr).send().expect("ping failed");
//! ```
//!
//! # Socket types
//!
//! Sending ICMP traffic over a [`RAW`] socket needs elevated privileges, while
//! a [`DGRAM`] socket works unprivileged on most systems. See [`SocketType`]
//! for the per-platform default and how to override it.
//!
//! [`IpAddr`]: std::net::IpAddr
pub use crateError;
pub use crate;