Skip to content

Commit cae8287

Browse files
Merge pull request #8 from brummer-simon/improve_readme
Add addiion examples to READMME.me
2 parents 5791ffe + 32f7f39 commit cae8287

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,33 @@
22

33
Rust 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

99
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.
1111
For example, it is easy to implement a custom Target to check if a Process is
1212
running 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
1734
use 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

Comments
 (0)