#async-read #progress #extension #traits #inspecting #future #tokio

async-read-progress

Extension traits for inspecting AsyncRead progress

2 unstable releases

0.2.0 Jun 13, 2021
0.1.0 Apr 29, 2020

#984 in Asynchronous

Download history 33/week @ 2024-03-13 36/week @ 2024-03-20 91/week @ 2024-03-27 80/week @ 2024-04-03 25/week @ 2024-04-10 39/week @ 2024-04-17 60/week @ 2024-04-24 121/week @ 2024-05-01 46/week @ 2024-05-08 79/week @ 2024-05-15 28/week @ 2024-05-22 93/week @ 2024-05-29 127/week @ 2024-06-05 21/week @ 2024-06-12 26/week @ 2024-06-19 110/week @ 2024-06-26

315 downloads per month
Used in 2 crates

MIT/Apache

14KB
297 lines

Async Read Progress

Context: Rust, async/await, async readers.

Extension traits for inspecting AsyncRead progress.

Supports futures 0.3 and tokio 0.2.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Report the progress of an async read operation

As promised on Twitter.

Examples

use futures::{
    io::AsyncReadExt,
    stream::{self, TryStreamExt},
};
use async_read_progress::*;

let src = vec![1u8, 2, 3, 4, 5];
let total_size = src.len();
let reader = stream::iter(vec![Ok(src)]).into_async_read();

let mut reader = reader.report_progress(
    /* only call every */ std::time::Duration::from_millis(20),
    |bytes_read| eprintln!("read {}/{}", bytes_read, total_size),
);
#

Dependencies

~0–1.2MB
~20K SLoC