22
33Rust crate to check if a "Target" is available. The crate comes with the trait
44"Target" and ICMP/TCP based implementations of it. Additionally, the crate offers
5- an async task Executor to perform availability checks of "Targets" on a regular basis.
5+ an async task executor to perform availability checks of "Targets" on a regular basis.
66
77## Usage
88
99With this crate you can easily check if a computer is currently reachable over the network.
10- Since all targets are implementations of trait "Target" the entire behavior is customizable.
10+ Since all targets are implementations of trait "Target" the availabilty check behavior is customizable.
1111For example, it is easy to implement a custom Target to check if a Process is
1212running or not.
1313
14- ## Example (from examples/async_usage/src/main.rs)
14+ ## Example (from examples/usage/src/main.rs)
15+
16+ ``` rust
17+ use std :: str :: FromStr ;
18+
19+ use reachable :: * ;
20+
21+ fn main () {
22+ // Construct ICMP Target and if its availabile
23+ let icmp_target = IcmpTarget :: from_str (" www.google.de" ). unwrap ();
24+ match icmp_target . check_availability () {
25+ Ok (status ) => println! (" {} is {}" , icmp_target . get_id (), status ),
26+ Err (error ) => println! (" Check failed for {} reason {}" , icmp_target . get_id (), error ),
27+ }
28+ }
29+ ```
30+
31+ ## Async Example (from examples/async_usage/src/main.rs)
1532
1633``` rust
1734use std :: str :: FromStr ;
@@ -35,7 +52,7 @@ fn main() {
3552 }
3653 };
3754
38- // Spawn Async executor
55+ // Spawn Async execution
3956 let mut exec = AsyncTargetExecutor :: new ();
4057 exec . start (vec! [
4158 AsyncTarget :: from ((icmp_target , handler , Duration :: from_secs (1 ))),
0 commit comments