From 21ffc9a9128fcf7d6ab04e17f4bdcf7e94e829d9 Mon Sep 17 00:00:00 2001 From: Fedor Gogolev Date: Wed, 6 Dec 2017 09:18:52 +0300 Subject: [PATCH] docs: add module documentation --- src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 92bf6a7..3707dd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,38 @@ +//! tokio-ping is an asynchronous ICMP pinging library. +//! +//! The repository is located at https://github.com/knsd/tokio-ping/. +//! +//! # Usage example +//! +//! Note, sending and receiving ICMP packets requires privileges. +//! +//! ``` +//! extern crate futures; +//! extern crate tokio_core; +//! extern crate tokio_ping; +//! +//! use futures::Stream; +//! +//! fn main() { +//! let addr = std::env::args().nth(1).unwrap().parse().unwrap(); +//! +//! let mut reactor = tokio_core::reactor::Core::new().unwrap(); +//! let pinger = tokio_ping::Pinger::new(&reactor.handle()).unwrap(); +//! let stream = pinger.chain(addr).stream(); +//! +//! let future = stream.take(3).for_each(|mb_time| { +//! match mb_time { +//! Some(time) => println!("time={}", time), +//! None => println!("timeout"), +//! } +//! Ok(()) +//! }); +//! +//! reactor.run(future).unwrap_or_default(); +//! } +//! +//! ``` + #[macro_use] extern crate error_chain; extern crate futures; extern crate lazy_socket;