@@ -64,6 +64,9 @@ pub trait DynNestedProgress: Progress + impls::Sealed {
64
64
/// An opaque type for storing [`DynNestedProgress`].
65
65
pub struct BoxedDynNestedProgress ( Box < dyn DynNestedProgress > ) ;
66
66
67
+ /// An owned version of [`Progress`] which can itself implement said trait.
68
+ pub type BoxedProgress = Box < dyn Progress > ;
69
+
67
70
/// A bridge type that implements [`NestedProgress`] for any type that implements [`DynNestedProgress`].
68
71
pub struct DynNestedProgressToNestedProgress < T : ?Sized > ( pub T ) ;
69
72
@@ -231,7 +234,7 @@ mod impls {
231
234
time:: Instant ,
232
235
} ;
233
236
234
- use crate :: traits:: Progress ;
237
+ use crate :: traits:: { BoxedProgress , Progress } ;
235
238
use crate :: {
236
239
messages:: MessageLevel ,
237
240
progress:: { Id , Step , StepShared } ,
@@ -407,6 +410,28 @@ mod impls {
407
410
}
408
411
}
409
412
413
+ impl Progress for BoxedProgress {
414
+ fn init ( & mut self , max : Option < Step > , unit : Option < Unit > ) {
415
+ self . deref_mut ( ) . init ( max, unit)
416
+ }
417
+
418
+ fn set_name ( & mut self , name : String ) {
419
+ self . deref_mut ( ) . set_name ( name)
420
+ }
421
+
422
+ fn name ( & self ) -> Option < String > {
423
+ self . deref ( ) . name ( )
424
+ }
425
+
426
+ fn id ( & self ) -> Id {
427
+ self . deref ( ) . id ( )
428
+ }
429
+
430
+ fn message ( & self , level : MessageLevel , message : String ) {
431
+ self . deref ( ) . message ( level, message)
432
+ }
433
+ }
434
+
410
435
impl Count for BoxedDynNestedProgress {
411
436
fn set ( & self , step : Step ) {
412
437
self . 0 . set ( step)
@@ -429,6 +454,28 @@ mod impls {
429
454
}
430
455
}
431
456
457
+ impl Count for BoxedProgress {
458
+ fn set ( & self , step : Step ) {
459
+ self . deref ( ) . set ( step)
460
+ }
461
+
462
+ fn step ( & self ) -> Step {
463
+ self . deref ( ) . step ( )
464
+ }
465
+
466
+ fn inc_by ( & self , step : Step ) {
467
+ self . deref ( ) . inc_by ( step)
468
+ }
469
+
470
+ fn inc ( & self ) {
471
+ self . deref ( ) . inc ( )
472
+ }
473
+
474
+ fn counter ( & self ) -> StepShared {
475
+ self . deref ( ) . counter ( )
476
+ }
477
+ }
478
+
432
479
impl NestedProgress for BoxedDynNestedProgress {
433
480
type SubProgress = Self ;
434
481
0 commit comments