Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcb2003/transfer-progress-rs
Rust crate to easily monitor the transfer of bytes from a reader to a writer
https://github.com/mcb2003/transfer-progress-rs
Last synced: 14 days ago
JSON representation
Rust crate to easily monitor the transfer of bytes from a reader to a writer
- Host: GitHub
- URL: https://github.com/mcb2003/transfer-progress-rs
- Owner: mcb2003
- License: apache-2.0
- Created: 2021-08-19T10:13:38.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-07T15:57:08.000Z (about 3 years ago)
- Last Synced: 2024-12-14T09:38:39.353Z (20 days ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Transfer Progress
A small rust crate that allows you to monitor the speed, progress and estimated
completion time of a transfer between a reader and a writer.Internally, this spins up a new thread for each transfer, and uses the
[progress-streams crate][progress-streams] to monitor it.[progress-streams]:
# Example
```rust
use std::{
fs::File,
io::{self, Read},
};use transfer_progress::Transfer;
fn main() -> io::Result<()> {
let reader = File::open("/dev/urandom")?.take(1024 * 1024 * 1024); // 1 GiB
let writer = io::sink();// Create the transfer monitor
let transfer = Transfer::new(reader, writer);while !transfer.is_complete() {
std::thread::sleep(std::time::Duration::from_secs(1));
// {:#} makes Transfer use SI units (MiB instead of MB)
println!("{:#}", transfer);
}// Catch any errors and retrieve the reader and writer
let (_reader, _writer) = transfer.finish()?;
Ok(())
}
```