@@ -3,7 +3,7 @@ use std::time::Instant;
3
3
use crate :: { messages:: MessageLevel , progress, progress:: Id , Unit } ;
4
4
5
5
/// A trait for describing hierarchical progress.
6
- pub trait Progress : Send {
6
+ pub trait Progress : Send + Sync {
7
7
/// The type of progress returned by [`add_child()`][Progress::add_child()].
8
8
type SubProgress : Progress ;
9
9
@@ -87,7 +87,7 @@ pub trait Progress: Send {
87
87
///
88
88
/// Use this to provide additional,human-readable information about the progress
89
89
/// made, including indicating success or failure.
90
- fn message ( & mut self , level : MessageLevel , message : impl Into < String > ) ;
90
+ fn message ( & self , level : MessageLevel , message : impl Into < String > ) ;
91
91
92
92
/// If available, return an atomic counter for direct access to the underlying state.
93
93
///
@@ -98,19 +98,19 @@ pub trait Progress: Send {
98
98
}
99
99
100
100
/// Create a message providing additional information about the progress thus far.
101
- fn info ( & mut self , message : impl Into < String > ) {
101
+ fn info ( & self , message : impl Into < String > ) {
102
102
self . message ( MessageLevel :: Info , message)
103
103
}
104
104
/// Create a message indicating the task is done successfully
105
- fn done ( & mut self , message : impl Into < String > ) {
105
+ fn done ( & self , message : impl Into < String > ) {
106
106
self . message ( MessageLevel :: Success , message)
107
107
}
108
108
/// Create a message indicating the task failed
109
- fn fail ( & mut self , message : impl Into < String > ) {
109
+ fn fail ( & self , message : impl Into < String > ) {
110
110
self . message ( MessageLevel :: Failure , message)
111
111
}
112
112
/// A shorthand to print throughput information
113
- fn show_throughput ( & mut self , start : Instant ) {
113
+ fn show_throughput ( & self , start : Instant ) {
114
114
let step = self . step ( ) ;
115
115
match self . unit ( ) {
116
116
Some ( unit) => self . show_throughput_with ( start, step, unit, MessageLevel :: Info ) ,
@@ -126,7 +126,7 @@ pub trait Progress: Send {
126
126
}
127
127
128
128
/// A shorthand to print throughput information, with the given step and unit, and message level.
129
- fn show_throughput_with ( & mut self , start : Instant , step : progress:: Step , unit : Unit , level : MessageLevel ) {
129
+ fn show_throughput_with ( & self , start : Instant , step : progress:: Step , unit : Unit , level : MessageLevel ) {
130
130
use std:: fmt:: Write ;
131
131
let elapsed = start. elapsed ( ) . as_secs_f32 ( ) ;
132
132
let steps_per_second = ( step as f32 / elapsed) as progress:: Step ;
@@ -159,7 +159,7 @@ pub trait Progress: Send {
159
159
/// It differs by not being able to add child progress dynamically, but in turn is object safe. It's recommended to
160
160
/// use this trait whenever there is no need to add child progress, at the leaf of a computation.
161
161
// NOTE: keep this in-sync with `Progress`.
162
- pub trait RawProgress : Send {
162
+ pub trait RawProgress : Send + Sync {
163
163
/// Initialize the Item for receiving progress information.
164
164
///
165
165
/// If `max` is `Some(…)`, it will be treated as upper bound. When progress is [set(…)](./struct.Item.html#method.set)
@@ -227,7 +227,7 @@ pub trait RawProgress: Send {
227
227
///
228
228
/// Use this to provide additional,human-readable information about the progress
229
229
/// made, including indicating success or failure.
230
- fn message ( & mut self , level : MessageLevel , message : String ) ;
230
+ fn message ( & self , level : MessageLevel , message : String ) ;
231
231
232
232
/// If available, return an atomic counter for direct access to the underlying state.
233
233
///
@@ -238,19 +238,19 @@ pub trait RawProgress: Send {
238
238
}
239
239
240
240
/// Create a message providing additional information about the progress thus far.
241
- fn info ( & mut self , message : String ) {
241
+ fn info ( & self , message : String ) {
242
242
self . message ( MessageLevel :: Info , message)
243
243
}
244
244
/// Create a message indicating the task is done successfully
245
- fn done ( & mut self , message : String ) {
245
+ fn done ( & self , message : String ) {
246
246
self . message ( MessageLevel :: Success , message)
247
247
}
248
248
/// Create a message indicating the task failed
249
- fn fail ( & mut self , message : String ) {
249
+ fn fail ( & self , message : String ) {
250
250
self . message ( MessageLevel :: Failure , message)
251
251
}
252
252
/// A shorthand to print throughput information
253
- fn show_throughput ( & mut self , start : Instant ) {
253
+ fn show_throughput ( & self , start : Instant ) {
254
254
let step = self . step ( ) ;
255
255
match self . unit ( ) {
256
256
Some ( unit) => self . show_throughput_with ( start, step, unit, MessageLevel :: Info ) ,
@@ -266,7 +266,7 @@ pub trait RawProgress: Send {
266
266
}
267
267
268
268
/// A shorthand to print throughput information, with the given step and unit, and message level.
269
- fn show_throughput_with ( & mut self , start : Instant , step : progress:: Step , unit : Unit , level : MessageLevel ) {
269
+ fn show_throughput_with ( & self , start : Instant , step : progress:: Step , unit : Unit , level : MessageLevel ) {
270
270
use std:: fmt:: Write ;
271
271
let elapsed = start. elapsed ( ) . as_secs_f32 ( ) ;
272
272
let steps_per_second = ( step as f32 / elapsed) as progress:: Step ;
@@ -400,31 +400,31 @@ mod impls {
400
400
<T as Progress >:: id ( self )
401
401
}
402
402
403
- fn message ( & mut self , level : MessageLevel , message : String ) {
403
+ fn message ( & self , level : MessageLevel , message : String ) {
404
404
<T as Progress >:: message ( self , level, message)
405
405
}
406
406
407
407
fn counter ( & self ) -> Option < StepShared > {
408
408
<T as Progress >:: counter ( self )
409
409
}
410
410
411
- fn info ( & mut self , message : String ) {
411
+ fn info ( & self , message : String ) {
412
412
<T as Progress >:: info ( self , message)
413
413
}
414
414
415
- fn done ( & mut self , message : String ) {
415
+ fn done ( & self , message : String ) {
416
416
<T as Progress >:: done ( self , message)
417
417
}
418
418
419
- fn fail ( & mut self , message : String ) {
419
+ fn fail ( & self , message : String ) {
420
420
<T as Progress >:: fail ( self , message)
421
421
}
422
422
423
- fn show_throughput ( & mut self , start : Instant ) {
423
+ fn show_throughput ( & self , start : Instant ) {
424
424
<T as Progress >:: show_throughput ( self , start)
425
425
}
426
426
427
- fn show_throughput_with ( & mut self , start : Instant , step : Step , unit : Unit , level : MessageLevel ) {
427
+ fn show_throughput_with ( & self , start : Instant , step : Step , unit : Unit , level : MessageLevel ) {
428
428
<T as Progress >:: show_throughput_with ( self , start, step, unit, level)
429
429
}
430
430
}
@@ -487,32 +487,32 @@ mod impls {
487
487
self . deref ( ) . id ( )
488
488
}
489
489
490
- fn message ( & mut self , level : MessageLevel , message : impl Into < String > ) {
491
- self . deref_mut ( ) . message ( level, message)
490
+ fn message ( & self , level : MessageLevel , message : impl Into < String > ) {
491
+ self . deref ( ) . message ( level, message)
492
492
}
493
493
494
494
fn counter ( & self ) -> Option < StepShared > {
495
495
self . deref ( ) . counter ( )
496
496
}
497
497
498
- fn info ( & mut self , message : impl Into < String > ) {
499
- self . deref_mut ( ) . info ( message)
498
+ fn info ( & self , message : impl Into < String > ) {
499
+ self . deref ( ) . info ( message)
500
500
}
501
501
502
- fn done ( & mut self , message : impl Into < String > ) {
503
- self . deref_mut ( ) . done ( message)
502
+ fn done ( & self , message : impl Into < String > ) {
503
+ self . deref ( ) . done ( message)
504
504
}
505
505
506
- fn fail ( & mut self , message : impl Into < String > ) {
507
- self . deref_mut ( ) . fail ( message)
506
+ fn fail ( & self , message : impl Into < String > ) {
507
+ self . deref ( ) . fail ( message)
508
508
}
509
509
510
- fn show_throughput ( & mut self , start : Instant ) {
511
- self . deref_mut ( ) . show_throughput ( start)
510
+ fn show_throughput ( & self , start : Instant ) {
511
+ self . deref ( ) . show_throughput ( start)
512
512
}
513
513
514
- fn show_throughput_with ( & mut self , start : Instant , step : Step , unit : Unit , level : MessageLevel ) {
515
- self . deref_mut ( ) . show_throughput_with ( start, step, unit, level)
514
+ fn show_throughput_with ( & self , start : Instant , step : Step , unit : Unit , level : MessageLevel ) {
515
+ self . deref ( ) . show_throughput_with ( start, step, unit, level)
516
516
}
517
517
}
518
518
}
0 commit comments