# HG changeset patch # User Raphaël Gomès # Date 2024-09-30 14:02:30 # Node ID 3ae7c43ad8aa5688da36fe6f849b2ad2a79db9f4 # Parent 7c105b953ca439ea3c0d1ab1b0074089223cff5c 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. diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -35,6 +35,7 @@ pub mod config; pub mod lock; pub mod logging; pub mod operations; +pub mod progress; pub mod revset; pub mod utils; pub mod vfs; diff --git a/rust/hg-core/src/progress.rs b/rust/hg-core/src/progress.rs new file mode 100644 --- /dev/null +++ b/rust/hg-core/src/progress.rs @@ -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); + /// Increment the current position and optionally the total + fn increment(&self, step: u64, total: Option); + /// Declare that progress is over and the progress bar should be deleted + fn complete(self); +}