changeset 52041:3ae7c43ad8aa

rust: add `Progress` trait for progress bars This will be used in the next few changes to introduce a progress bar for the `hg update` fastpath.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 30 Sep 2024 16:02:30 +0200
parents 7c105b953ca4
children 92e23ba257d1
files rust/hg-core/src/lib.rs rust/hg-core/src/progress.rs
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/lib.rs	Mon Sep 30 19:15:19 2024 +0200
+++ b/rust/hg-core/src/lib.rs	Mon Sep 30 16:02:30 2024 +0200
@@ -35,6 +35,7 @@
 pub mod lock;
 pub mod logging;
 pub mod operations;
+pub mod progress;
 pub mod revset;
 pub mod utils;
 pub mod vfs;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hg-core/src/progress.rs	Mon Sep 30 16:02:30 2024 +0200
@@ -0,0 +1,11 @@
+//! Progress-bar related things
+
+/// A generic determinate progress bar trait
+pub trait Progress: Send + Sync + 'static {
+    /// Set the current position and optionally the total
+    fn update(&self, pos: u64, total: Option<u64>);
+    /// Increment the current position and optionally the total
+    fn increment(&self, step: u64, total: Option<u64>);
+    /// Declare that progress is over and the progress bar should be deleted
+    fn complete(self);
+}