#ping #parse #cross-platform #execute #output #command #macos

pinger

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

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

Download history 121/week @ 2024-07-01 62/week @ 2024-07-08 113/week @ 2024-07-15 529/week @ 2024-07-22 121/week @ 2024-07-29 78/week @ 2024-08-05 55/week @ 2024-08-12 82/week @ 2024-08-19 46/week @ 2024-08-26 53/week @ 2024-09-02 100/week @ 2024-09-09 117/week @ 2024-09-16 106/week @ 2024-09-23 78/week @ 2024-09-30 71/week @ 2024-10-07 85/week @ 2024-10-14

351 downloads per month
Used in 2 crates

MIT license

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