Skip to main content

winping/
lib.rs

1//! winping - Easy ICMP Echo for Windows, and no elevated rights required!
2//!
3//! Published on crates.io as `winping-rs`, a maintained fork of the `winping` crate and a drop-in
4//! replacement for it. The library target keeps the name `winping`, so `use winping::...` works
5//! unchanged.
6//!
7//! Super basic ping.exe example
8//!
9//! ```rust
10//! use std::net::IpAddr;
11//! use winping::{Buffer, Pinger};
12//!
13//! fn main() {
14//!     let dst = std::env::args()
15//!         .nth(1)
16//!         .unwrap_or(String::from("127.0.0.1"))
17//!         .parse::<IpAddr>()
18//!         .expect("Could not parse IP Address");
19//!
20//!     let pinger = Pinger::new().unwrap();
21//!     let mut buffer = Buffer::new();
22//!
23//!     for _ in 0..4 {
24//!         match pinger.send(dst, &mut buffer) {
25//!             Ok(rtt) => println!("Response time {} ms.", rtt),
26//!             Err(err) => println!("{}.", err),
27//!         }
28//!     }
29//! }
30//! ```
31//!
32#![cfg(any(target_os = "windows", doc))]
33#![forbid(unreachable_patterns)]
34#![allow(clippy::needless_doctest_main)]
35
36#[cfg(feature = "async")]
37mod async_pinger;
38mod buffer;
39mod error;
40mod pinger;
41pub(crate) mod util;
42
43#[cfg(feature = "async")]
44pub use async_pinger::{AsyncPinger, AsyncResult, PingFuture, set_async_buffer_size};
45pub use buffer::Buffer;
46pub use error::Error;
47// Only the integration tests use `futures`; acknowledge it for the lib's own
48// test target, which still exists for doctests and util's unit test.
49#[cfg(test)]
50use futures as _;
51pub use pinger::{CreateError, IpPair, Pinger};