2
2
3
3
Rust crate to check if a "Target" is available. The crate comes with the trait
4
4
"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.
6
6
7
7
## Usage
8
8
9
9
With 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.
11
11
For example, it is easy to implement a custom Target to check if a Process is
12
12
running or not.
13
13
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)
15
32
16
33
``` rust
17
34
use std :: str :: FromStr ;
@@ -35,7 +52,7 @@ fn main() {
35
52
}
36
53
};
37
54
38
- // Spawn Async executor
55
+ // Spawn Async execution
39
56
let mut exec = AsyncTargetExecutor :: new ();
40
57
exec . start (vec! [
41
58
AsyncTarget :: from ((icmp_target , handler , Duration :: from_secs (1 ))),
0 commit comments