rpb

Crates.iorpb
lib.rsrpb
version0.1.5
sourcesrc
created_at2022-10-09 18:34:28.711517
updated_at2022-10-17 16:09:55.258338
descriptionA simple implementation of progress bar for rust
homepage
repositoryhttps://github.com/disco07/rpb
max_upload_size
id684118
size10,435,268
Drissa Koné (disco07)

documentation

https://docs.rs/rpb

README

Rust Crates.io Documentation

rpb

A simple progress bar for Rust 🦀 projects. I created that because there was a long processes in some project and I didn't know what was the progression.

Installation

Add from command line.

cargo add rpb@0.1.5

Or add this to your Cargo.toml file.

[dependencies]
rpb = "0.1.5"

# Or add from github main branch.
rpb = { git = "https://github.com/disco07/rpb.git", branch = "main" }

Usage

Basic usage

fn main() {
    use rpb::bar::Bar;
    use std::thread::sleep;
    use std::time;
    
    let mut bar = Bar::new(200);

    for _i in 0..200 {
        bar.add(1);
        sleep(time::Duration::from_millis(50))
    }
}

Basic bar examples/custom.rs Custom bar

I/O operations

The rpb implements an io writer and io reader so it can automatically detect the number of bytes written to a stream.

use rpb::bar::Bar;
use std::fs::File;
use std::io;

fn main() -> io::Result<()> {
    let source = File::open("data.sql")?;
    let mut target = File::create("src.sql")?;
    let bar = Bar::default_bytes(source.metadata()?.len() as i64, "downloading");
    io::copy(&mut bar.reader(source), &mut target).unwrap();
    Ok(())
}

Custom bar

Contributing 🤝

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

📝 License

License: MIT

Commit count: 207

cargo fmt