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

pinger

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

40 releases (7 stable)

new 1.3.0 Nov 16, 2024
1.2.3 Jul 21, 2024
1.1.1 Feb 17, 2024
1.1.0 Nov 29, 2023
0.3.1 Nov 29, 2020

#58 in #ping

Download history 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 44/week @ 2024-10-21 50/week @ 2024-10-28 54/week @ 2024-11-04 211/week @ 2024-11-11

369 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–13MB
~140K SLoC