#future #async

async-copy-progress

Asynchronous copying with progress callbacks

2 stable releases

1.0.1 May 26, 2021

#801 in Asynchronous

28 downloads per month

MIT/Apache

10KB
60 lines

async-copy-progress

github crates.io docs.rs build status

Asynchronous copies with progress updates.

This library provides an asynchronous copy function which calls a function with the current progress after each step.

[dependencies]
async-copy-progress = "1.0"

Example

let mut reader: &[u8] = b"hello";
let mut writer: Vec<u8> = vec![];

let progress = AtomicU64::new(0);
let report_progress = |amt| progress.store(amt, Ordering::Relaxed);

async_copy_progress::copy(&mut reader, &mut writer, report_progress).await?;

assert_eq!(&b"hello"[..], &writer[..]);
assert_eq!(5, progress.load(Ordering::Relaxed));

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~86KB