#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

#1226 in Asynchronous

Download history 20/week @ 2024-07-19 28/week @ 2024-07-26 21/week @ 2024-08-02 15/week @ 2024-08-09 13/week @ 2024-08-16 11/week @ 2024-08-23 21/week @ 2024-08-30 8/week @ 2024-09-06 7/week @ 2024-09-13 19/week @ 2024-09-20 29/week @ 2024-09-27 32/week @ 2024-10-04 32/week @ 2024-10-11 21/week @ 2024-10-18 11/week @ 2024-10-25 28/week @ 2024-11-01

94 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–5.5MB
~20K SLoC