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

pinger

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

41 releases (8 stable)

new 2.0.0 Dec 18, 2024
1.3.0 Nov 16, 2024
1.2.3 Jul 21, 2024
1.1.1 Feb 17, 2024
0.3.1 Nov 29, 2020

#58 in #ping

Download history 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 221/week @ 2024-11-18 125/week @ 2024-11-25 139/week @ 2024-12-02 178/week @ 2024-12-09

790 downloads per month
Used in 2 crates

MIT license

29KB
724 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.3–5MB
~97K SLoC