Trait gitoxide_core::pack::receive::Progress
pub trait Progress: Send + Sync {
type SubProgress: Progress;
Show 20 methods
// Required methods
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress;
fn add_child_with_id(
&mut self,
name: impl Into<String>,
id: [u8; 4]
) -> Self::SubProgress;
fn init(&mut self, max: Option<usize>, unit: Option<Unit>);
fn set(&mut self, step: usize);
fn step(&self) -> usize;
fn inc_by(&mut self, step: usize);
fn set_name(&mut self, name: impl Into<String>);
fn name(&self) -> Option<String>;
fn id(&self) -> [u8; 4];
fn message(&self, level: MessageLevel, message: impl Into<String>);
// Provided methods
fn unit(&self) -> Option<Unit> { ... }
fn max(&self) -> Option<usize> { ... }
fn set_max(&mut self, _max: Option<usize>) -> Option<usize> { ... }
fn inc(&mut self) { ... }
fn counter(&self) -> Option<Arc<AtomicUsize, Global>> { ... }
fn info(&self, message: impl Into<String>) { ... }
fn done(&self, message: impl Into<String>) { ... }
fn fail(&self, message: impl Into<String>) { ... }
fn show_throughput(&self, start: Instant) { ... }
fn show_throughput_with(
&self,
start: Instant,
step: usize,
unit: Unit,
level: MessageLevel
) { ... }
}
async-client
or blocking-client
only.Expand description
A trait for describing hierarchical progress.
Required Associated Types§
type SubProgress: Progress
type SubProgress: Progress
The type of progress returned by add_child()
.
Required Methods§
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress
Adds a new child, whose parent is this instance, with the given name
.
This will make the child progress to appear contained in the parent progress.
Note that such progress does not have a stable identifier, which can be added
with add_child_with_id()
if desired.
fn add_child_with_id(
&mut self,
name: impl Into<String>,
id: [u8; 4]
) -> Self::SubProgress
fn add_child_with_id( &mut self, name: impl Into<String>, id: [u8; 4] ) -> Self::SubProgress
Adds a new child, whose parent is this instance, with the given name
and id
.
This will make the child progress to appear contained in the parent progress, and it can be identified
using id
.
fn init(&mut self, max: Option<usize>, unit: Option<Unit>)
fn init(&mut self, max: Option<usize>, unit: Option<Unit>)
Initialize the Item for receiving progress information.
If max
is Some(…)
, it will be treated as upper bound. When progress is set(…)
it should not exceed the given maximum.
If max
is None
, the progress is unbounded. Use this if the amount of work cannot accurately
be determined in advance.
If unit
is Some(…)
, it is used for display purposes only. See prodash::Unit
for more information.
If both unit
and max
are None
, the item will be reset to be equivalent to ‘uninitialized’.
If this method is never called, this Progress
instance will serve as organizational unit, useful to add more structure
to the progress tree (e.g. a headline).
Note that this method can be called multiple times, changing the bounded-ness and unit at will.
fn set(&mut self, step: usize)
fn set(&mut self, step: usize)
Set the current progress to the given step
. The cost of this call is negligible,
making manual throttling not necessary.
Note: that this call has no effect unless init(…)
was called before.
fn inc_by(&mut self, step: usize)
fn inc_by(&mut self, step: usize)
Increment the current progress to the given step
.
The cost of this call is negligible, making manual throttling not necessary.
fn set_name(&mut self, name: impl Into<String>)
fn set_name(&mut self, name: impl Into<String>)
Set the name of the instance, altering the value given when crating it with add_child(…)
The progress is allowed to discard it.
fn name(&self) -> Option<String>
fn name(&self) -> Option<String>
Get the name of the instance as given when creating it with add_child(…)
The progress is allowed to not be named, thus there is no guarantee that a previously set names ‘sticks’.
Provided Methods§
fn max(&self) -> Option<usize>
fn max(&self) -> Option<usize>
Returns the maximum about of items we expect, as provided with the init(…)
call
fn set_max(&mut self, _max: Option<usize>) -> Option<usize>
fn set_max(&mut self, _max: Option<usize>) -> Option<usize>
Set the maximum value to max
and return the old maximum value.
fn inc(&mut self)
fn inc(&mut self)
Increment the current progress to the given 1. The cost of this call is negligible, making manual throttling not necessary.
fn counter(&self) -> Option<Arc<AtomicUsize, Global>>
fn counter(&self) -> Option<Arc<AtomicUsize, Global>>
If available, return an atomic counter for direct access to the underlying state.
This is useful if multiple threads want to access the same progress, without the need for provide each their own progress and aggregating the result.
fn info(&self, message: impl Into<String>)
fn info(&self, message: impl Into<String>)
Create a message providing additional information about the progress thus far.
fn show_throughput(&self, start: Instant)
fn show_throughput(&self, start: Instant)
A shorthand to print throughput information
fn show_throughput_with(
&self,
start: Instant,
step: usize,
unit: Unit,
level: MessageLevel
)
fn show_throughput_with( &self, start: Instant, step: usize, unit: Unit, level: MessageLevel )
A shorthand to print throughput information, with the given step and unit, and message level.