Skip to content

Commit 287ed6d

Browse files
committed
add simplified file input example to readme
1 parent 81d791a commit 287ed6d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,37 @@ parse ADIF data in Rust on top of tokio.
1616

1717
## Usage
1818

19+
Add the dependency:
20+
1921
```sh
2022
cargo add TBD
2123
```
2224

25+
Then start reading ADIF from any object that implements the AsyncRead trait:
26+
27+
```rust,no_run
28+
# use adif::RecordStream;
29+
# use futures::StreamExt;
30+
# use tokio::fs::File;
31+
# use tokio::io::BufReader;
32+
#
33+
# #[tokio::main(flavor = "current_thread")]
34+
# async fn main() -> Result<(), Box<dyn std::error::Error>> {
35+
# let path = "";
36+
let file = File::open(path).await?;
37+
let reader = BufReader::new(file);
38+
let mut stream = RecordStream::new(reader, true);
39+
40+
while let Some(result) = stream.next().await {
41+
let record = result?;
42+
if let Some(call) = record.get("call") {
43+
println!("call: {}", call.as_str());
44+
}
45+
}
46+
#
47+
# Ok(())
48+
# }
49+
```
2350
See examples or documentation for further information.
2451

2552
## Features

0 commit comments

Comments
 (0)