39 releases (6 stable)
1.2.3 | Jul 21, 2024 |
---|---|
1.1.1 | Feb 17, 2024 |
1.1.0 | Nov 29, 2023 |
0.14.0 | Nov 7, 2023 |
0.3.1 | Nov 29, 2020 |
#52 in #ping
351 downloads per month
Used in 2 crates
22KB
547 lines
pinger
A small cross-platform library to execute the ping command and parse the output.
This crate is primarily built for use with gping
, but it can also be used as a
standalone library.
This allows you to reliably ping hosts without having to worry about process permissions, in a cross-platform manner on Windows, Linux and macOS.
Usage
A full example of using the library can be found in the examples/
directory, but the
interface is quite simple:
use pinger::ping;
fn ping_google() {
let stream = ping("google.com", None).expect("Error pinging");
for message in stream {
match message {
pinger::PingResult::Pong(duration, _) => {
println!("Duration: {:?}", duration)
}
_ => {} // Handle errors, log ping timeouts, etc.
}
}
}
Adding pinger to your project.
cargo add pinger
Dependencies
~3–16MB
~146K SLoC