#command-output #cross-platform #run-command #ping #parser

pinger

A small cross-platform library to execute the ping command and parse the output

43 releases (10 stable)

2.1.1 Aug 15, 2025
2.0.0 Dec 18, 2024
1.3.0 Nov 16, 2024
1.2.3 Jul 21, 2024
0.3.1 Nov 29, 2020

#34 in #command-output

Download history 142/week @ 2025-09-15 120/week @ 2025-09-22 162/week @ 2025-09-29 154/week @ 2025-10-06 191/week @ 2025-10-13 148/week @ 2025-10-20 156/week @ 2025-10-27 96/week @ 2025-11-03 81/week @ 2025-11-10 85/week @ 2025-11-17 151/week @ 2025-11-24 121/week @ 2025-12-01 99/week @ 2025-12-08 141/week @ 2025-12-15 87/week @ 2025-12-22 75/week @ 2025-12-29

412 downloads per month
Used in 4 crates

MIT license

29KB
738 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 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.
        }
    }
}

Adding pinger to your project.

cargo add pinger

Dependencies

~2.2–5MB
~94K SLoC