Trait prodash::Progress [−][src]
pub trait Progress: Send + 'static { type SubProgress: Progress;}Show methods
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress; fn init(&mut self, max: Option<Step>, unit: Option<Unit>); fn set(&mut self, step: Step); fn step(&self) -> Step; fn inc_by(&mut self, step: Step); fn set_name(&mut self, name: impl Into<String>); fn name(&self) -> Option<String>; fn message(&mut self, level: MessageLevel, message: impl Into<String>); fn unit(&self) -> Option<Unit> { ... } fn max(&self) -> Option<Step> { ... } fn inc(&mut self) { ... } fn info(&mut self, message: impl Into<String>) { ... } fn done(&mut self, message: impl Into<String>) { ... } fn fail(&mut self, message: impl Into<String>) { ... } fn show_throughput(&mut self, start: Instant) { ... } fn show_throughput_with(&mut self, start: Instant, step: Step, unit: Unit) { ... }
A trait for describing hierarchical process.
Associated Types
type SubProgress: Progress
[src]
The type of progress returned by add_child()
.
Required methods
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress
[src]
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.
fn init(&mut self, max: Option<Step>, unit: Option<Unit>)
[src]
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 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: Step)
[src]
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 step(&self) -> Step
[src]
Returns the current step, as controlled by inc*(…)
calls
fn inc_by(&mut self, step: Step)
[src]
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>)
[src]
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>
[src]
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’.
fn message(&mut self, level: MessageLevel, message: impl Into<String>)
[src]
Create a message
of the given level
and store it with the progress tree.
Use this to provide additional,human-readable information about the progress made, including indicating success or failure.
Provided methods
fn unit(&self) -> Option<Unit>
[src]
Returns the (cloned) unit associated with this Progress
fn max(&self) -> Option<Step>
[src]
Returns the maximum about of items we expect, as provided with the init(…)
call
fn inc(&mut self)
[src]
Increment the current progress to the given 1. The cost of this call is negligible, making manual throttling not necessary.
fn info(&mut self, message: impl Into<String>)
[src]
Create a message providing additional information about the progress thus far.
fn done(&mut self, message: impl Into<String>)
[src]
Create a message indicating the task is done successfully
fn fail(&mut self, message: impl Into<String>)
[src]
Create a message indicating the task failed
fn show_throughput(&mut self, start: Instant)
[src]
A shorthand to print throughput information
fn show_throughput_with(&mut self, start: Instant, step: Step, unit: Unit)
[src]
A shorthand to print throughput information, with the given step and unit
Implementors
impl Progress for Discard
[src]
impl Progress for Discard
[src]type SubProgress = Discard
fn add_child(&mut self, _name: impl Into<String>) -> Self::SubProgress
[src]
fn init(&mut self, _max: Option<usize>, _unit: Option<Unit>)
[src]
fn set(&mut self, _step: usize)
[src]
fn step(&self) -> usize
[src]
fn inc_by(&mut self, _step: usize)
[src]
fn set_name(&mut self, _name: impl Into<String>)
[src]
fn name(&self) -> Option<String>
[src]
fn message(&mut self, _level: MessageLevel, _message: impl Into<String>)
[src]
impl Progress for Log
[src]
impl Progress for Log
[src]type SubProgress = Log
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress
[src]
fn init(&mut self, max: Option<usize>, unit: Option<Unit>)
[src]
fn set(&mut self, step: usize)
[src]
fn unit(&self) -> Option<Unit>
[src]
fn max(&self) -> Option<usize>
[src]
fn step(&self) -> usize
[src]
fn inc_by(&mut self, step: usize)
[src]
fn set_name(&mut self, name: impl Into<String>)
[src]
fn name(&self) -> Option<String>
[src]
fn message(&mut self, level: MessageLevel, message: impl Into<String>)
[src]
impl Progress for Item
[src]
impl Progress for Item
[src]type SubProgress = Item
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress
[src]
fn init(&mut self, max: Option<usize>, unit: Option<Unit>)
[src]
fn set(&mut self, step: usize)
[src]
fn unit(&self) -> Option<Unit>
[src]
fn max(&self) -> Option<usize>
[src]
fn step(&self) -> usize
[src]
fn inc_by(&mut self, step: usize)
[src]
fn set_name(&mut self, name: impl Into<String>)
[src]
fn name(&self) -> Option<String>
[src]
fn message(&mut self, level: MessageLevel, message: impl Into<String>)
[src]
impl<L, R> Progress for Either<L, R> where
L: Progress,
R: Progress,
[src]
impl<L, R> Progress for Either<L, R> where
L: Progress,
R: Progress,
[src]type SubProgress = Either<L::SubProgress, R::SubProgress>
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress
[src]
fn init(&mut self, max: Option<usize>, unit: Option<Unit>)
[src]
fn set(&mut self, step: usize)
[src]
fn unit(&self) -> Option<Unit>
[src]
fn max(&self) -> Option<usize>
[src]
fn step(&self) -> usize
[src]
fn inc_by(&mut self, step: usize)
[src]
fn set_name(&mut self, name: impl Into<String>)
[src]
fn name(&self) -> Option<String>
[src]
fn message(&mut self, level: MessageLevel, message: impl Into<String>)
[src]
impl<T> Progress for DoOrDiscard<T> where
T: Progress,
[src]
impl<T> Progress for DoOrDiscard<T> where
T: Progress,
[src]type SubProgress = DoOrDiscard<T::SubProgress>
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress
[src]
fn init(&mut self, max: Option<usize>, unit: Option<Unit>)
[src]
fn set(&mut self, step: usize)
[src]
fn unit(&self) -> Option<Unit>
[src]
fn max(&self) -> Option<usize>
[src]
fn step(&self) -> usize
[src]
fn inc_by(&mut self, step: usize)
[src]
fn set_name(&mut self, name: impl Into<String>)
[src]
fn name(&self) -> Option<String>
[src]
fn message(&mut self, level: MessageLevel, message: impl Into<String>)
[src]
impl<T: Progress> Progress for ThroughputOnDrop<T>
[src]
impl<T: Progress> Progress for ThroughputOnDrop<T>
[src]