#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

#1141 in Asynchronous

Download history 31/week @ 2023-12-01 1/week @ 2023-12-08 40/week @ 2023-12-15 7/week @ 2023-12-22 9/week @ 2023-12-29 26/week @ 2024-01-05 68/week @ 2024-01-12 101/week @ 2024-01-19 47/week @ 2024-01-26 89/week @ 2024-02-02 112/week @ 2024-02-09 43/week @ 2024-02-16 21/week @ 2024-02-23 19/week @ 2024-03-01 39/week @ 2024-03-08 20/week @ 2024-03-15

106 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