| @@ -38,6 +38,20 @@ pub trait Progress { · 37 unmodified lines |
| 38 | 38 | /// **Note**: that this call has no effect unless `init(…)` was called before. |
| 39 | 39 | fn set(&mut self, step: u32); |
| 40 | 40 | |
| 41 | + /// Increment the current progress to the given `step`. The cost of this call is negligible, |
| 42 | + /// making manual throttling *not* necessary. |
| 43 | + /// |
| 44 | + /// **Note**: that this call has no effect unless `init(…)` was called before. |
| 45 | + fn inc_by(&mut self, step: u32); |
| 46 | + |
| 47 | + /// Increment the current progress to the given 1. The cost of this call is negligible, |
| 48 | + /// making manual throttling *not* necessary. |
| 49 | + /// |
| 50 | + /// **Note**: that this call has no effect unless `init(…)` was called before. |
| 51 | + fn inc(&mut self) { |
| 52 | + self.inc_by(1) |
| 53 | + } |
| 54 | + |
| 41 | 55 | /// Create a `message` of the given `level` and store it with the progress tree. |
| 42 | 56 | /// |
| 43 | 57 | /// Use this to provide additional,human-readable information about the progress |
| @@ -71,6 +85,8 @@ impl Progress for Discard { · 27 unmodified lines |
| 71 | 85 | |
| 72 | 86 | fn set(&mut self, _step: u32) {} |
| 73 | 87 | |
| 88 | + fn inc_by(&mut self, _step: u32) {} |
| 89 | + |
| 74 | 90 | fn message(&mut self, _level: MessageLevel, _message: impl Into<String>) {} |
| 75 | 91 | } |
| 76 | 92 | |
| @@ -107,6 +123,13 @@ where · 30 unmodified lines |
| 107 | 123 | } |
| 108 | 124 | } |
| 109 | 125 | |
| 126 | + fn inc_by(&mut self, step: u32) { |
| 127 | + match self { |
| 128 | + Either::Left(l) => l.inc_by(step), |
| 129 | + Either::Right(r) => r.inc_by(step), |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 110 | 133 | fn message(&mut self, level: MessageLevel, message: impl Into<String>) { |
| 111 | 134 | match self { |
| 112 | 135 | Either::Left(l) => l.message(level, message), |
| @@ -147,6 +170,10 @@ where · 34 unmodified lines |
| 147 | 170 | self.0.set(step) |
| 148 | 171 | } |
| 149 | 172 | |
| 173 | + fn inc_by(&mut self, step: u32) { |
| 174 | + self.0.inc_by(step) |
| 175 | + } |
| 176 | + |
| 150 | 177 | fn message(&mut self, level: MessageLevel, message: impl Into<String>) { |
| 151 | 178 | self.0.message(level, message) |
| 152 | 179 | } |