| Crates.io | pinger |
| lib.rs | pinger |
| version | 2.1.1 |
| created_at | 2020-11-02 14:56:23.774118+00 |
| updated_at | 2025-08-15 12:47:07.180523+00 |
| description | A small cross-platform library to execute the ping command and parse the output |
| homepage | |
| repository | https://github.com/orf/pinger/ |
| max_upload_size | |
| id | 307916 |
| size | 49,355 |
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.
A full example of using the library can be found in the examples/ directory, but the
interface is quite simple:
use std::time::Duration;
use pinger::{ping, PingOptions};
fn ping_google() {
let options = PingOptions::new("google.com", Duration::from_secs(1), None);
let stream = ping(options).expect("Error pinging");
for message in stream {
match message {
pinger::PingResult::Pong(duration, _) => {
println!("Duration: {:?}", duration)
}
_ => {} // Handle errors, log ping timeouts, etc.
}
}
}
cargo add pinger