summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-02-28 18:01:33 +0800
committer魏曹先生 <1992414357@qq.com>2026-02-28 18:49:31 +0800
commit05b7b483056902a07f83bc14f443ab59ce1471d8 (patch)
treee46c9e5e672a6d0e9baf4bca09ea159ad669f881 /README.md
First version0.1.1
Diffstat (limited to 'README.md')
-rw-r--r--README.md97
1 files changed, 97 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..517ae53
--- /dev/null
+++ b/README.md
@@ -0,0 +1,97 @@
+# just_progress
+
+> Just a progress display tool
+
+## Usage
+
+```rust
+use just_progress::progress;
+use just_progress::renderer::ProgressSimpleRenderer;
+use tokio::time::{sleep, Duration};
+use tokio::join;
+
+#[tokio::main]
+async fn main() {
+ // Initialize the progress center
+ let center = progress::init();
+
+ // Create a renderer and enable subprogress display
+ let renderer = ProgressSimpleRenderer::new().with_subprogress(true);
+
+ // Bind the renderer callback function
+ let bind = progress::bind(center, move |name, state| renderer.update(name, state));
+
+ // Concurrently execute progress binding and business logic
+ join!(bind, proc());
+}
+
+async fn proc() {
+ println!("Starting package download!");
+ sleep(Duration::from_millis(500)).await;
+
+ // Define multiple concurrent download tasks
+ let download_task = async {
+ for i in 1..21 {
+ sleep(Duration::from_millis(50)).await;
+ progress::update_progress("Download/Data", i as f32 * 0.05);
+ }
+ };
+
+ let extract_task = async {
+ for i in 1..11 {
+ sleep(Duration::from_millis(100)).await;
+ progress::update_progress("Download/Extract", i as f32 * 0.1);
+ }
+ };
+
+ let verify_sha256_task = async {
+ for i in 1..6 {
+ sleep(Duration::from_millis(300)).await;
+ progress::update_progress("Download/Verify/SHA256", i as f32 * 0.2);
+ }
+ };
+
+ let verify_md5_task = async {
+ for i in 1..6 {
+ sleep(Duration::from_millis(100)).await;
+ progress::update_progress("Download/Verify/MD5", i as f32 * 0.2);
+ }
+ };
+
+ let verify_blake3_task = async {
+ for i in 1..6 {
+ sleep(Duration::from_millis(500)).await;
+ progress::update_progress("Download/Verify/Blake3", i as f32 * 0.2);
+ }
+ };
+
+ // Concurrently execute all download tasks
+ join!(
+ download_task,
+ extract_task,
+ verify_sha256_task,
+ verify_blake3_task,
+ verify_md5_task
+ );
+
+ sleep(Duration::from_millis(500)).await;
+ progress::clear_all(); // Clear all progress after download completes
+ println!("Package download complete!");
+
+ progress::close(); // Close the progress channel, ending the program
+}
+```
+
+## Installation
+
+Add this to your `Cargo.toml`:
+
+```toml
+[dependencies]
+just_progress = "0.1"
+```
+
+## License
+
+This project is dual-licensed under MIT and Apache 2.0.
+See the LICENSE file for details.