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

pinger

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

36 releases (3 stable)

1.1.1 Feb 17, 2024
1.1.0 Nov 29, 2023
0.14.0 Nov 7, 2023
0.13.0 Jul 31, 2023
0.3.1 Nov 29, 2020

#55 in #ping

Download history 42/week @ 2024-01-01 63/week @ 2024-01-08 50/week @ 2024-01-15 47/week @ 2024-01-22 55/week @ 2024-01-29 50/week @ 2024-02-05 274/week @ 2024-02-12 353/week @ 2024-02-19 148/week @ 2024-02-26 91/week @ 2024-03-04 94/week @ 2024-03-11 103/week @ 2024-03-18 96/week @ 2024-03-25 101/week @ 2024-04-01 69/week @ 2024-04-08 72/week @ 2024-04-15

350 downloads per month
Used in gping

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–15MB
~159K SLoC