Trait gix::Progress

pub trait Progress: Count + Send + Sync {
Show 13 methods // Required methods fn init(&mut self, max: Option<usize>, unit: Option<Unit>); fn set_name(&mut self, name: String); fn name(&self) -> Option<String>; fn id(&self) -> [u8; 4]; fn message(&self, level: MessageLevel, message: String); // Provided methods fn unit(&self) -> Option<Unit> { ... } fn max(&self) -> Option<usize> { ... } fn set_max(&mut self, _max: Option<usize>) -> Option<usize> { ... } fn info(&self, message: String) { ... } fn done(&self, message: String) { ... } fn fail(&self, message: String) { ... } fn show_throughput(&self, start: Instant) { ... } fn show_throughput_with( &self, start: Instant, step: usize, unit: Unit, level: MessageLevel ) { ... }
}
Expand description

A trait for describing non-hierarchical progress.

It differs by not being able to add child progress dynamically, but in turn is object safe. It’s recommended to use this trait whenever there is no need to add child progress, at the leaf of a computation.

Required Methods§

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_name(&mut self, name: 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>

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 id(&self) -> [u8; 4]

Get a stable identifier for the progress instance. Note that it could be unknown.

fn message(&self, level: MessageLevel, message: String)

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>

Returns the (cloned) unit associated with this Progress

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>

Set the maximum value to max and return the old maximum value.

fn info(&self, message: String)

Create a message providing additional information about the progress thus far.

fn done(&self, message: String)

Create a message indicating the task is done successfully

fn fail(&self, message: String)

Create a message indicating the task failed

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 )

A shorthand to print throughput information, with the given step and unit, and message level.

Trait Implementations§

§

impl Count for Box<dyn Progress, Global>

§

fn set(&self, step: usize)

Set the current progress to the given step. The cost of this call is negligible, making manual throttling not necessary. Read more
§

fn step(&self) -> usize

Returns the current step, as controlled by inc*(…) calls
§

fn inc_by(&self, step: usize)

Increment the current progress to the given step. The cost of this call is negligible, making manual throttling not necessary.
§

fn inc(&self)

Increment the current progress to the given 1. The cost of this call is negligible, making manual throttling not necessary.
§

fn counter(&self) -> Arc<AtomicUsize, Global>

Return an atomic counter for direct access to the underlying state. Read more
§

impl Progress for Box<dyn Progress, Global>

§

fn init(&mut self, max: Option<usize>, unit: Option<Unit>)

Initialize the Item for receiving progress information. Read more
§

fn unit(&self) -> Option<Unit>

Returns the (cloned) unit associated with this Progress
§

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>

Set the maximum value to max and return the old maximum value.
§

fn set_name(&mut self, name: 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>

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 id(&self) -> [u8; 4]

Get a stable identifier for the progress instance. Note that it could be unknown.
§

fn message(&self, level: MessageLevel, message: String)

Create a message of the given level and store it with the progress tree. Read more
§

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 )

A shorthand to print throughput information, with the given step and unit, and message level.
§

fn info(&self, message: String)

Create a message providing additional information about the progress thus far.
§

fn done(&self, message: String)

Create a message indicating the task is done successfully
§

fn fail(&self, message: String)

Create a message indicating the task failed

Implementations on Foreign Types§

§

impl Progress for Box<dyn Progress, Global>

§

fn init(&mut self, max: Option<usize>, unit: Option<Unit>)

§

fn unit(&self) -> Option<Unit>

§

fn max(&self) -> Option<usize>

§

fn set_max(&mut self, max: Option<usize>) -> Option<usize>

§

fn set_name(&mut self, name: String)

§

fn name(&self) -> Option<String>

§

fn id(&self) -> [u8; 4]

§

fn message(&self, level: MessageLevel, message: String)

§

fn show_throughput(&self, start: Instant)

§

fn show_throughput_with( &self, start: Instant, step: usize, unit: Unit, level: MessageLevel )

§

impl<'a, T> Progress for &'a mut Twhere T: Progress + ?Sized,

§

fn init(&mut self, max: Option<usize>, unit: Option<Unit>)

§

fn unit(&self) -> Option<Unit>

§

fn max(&self) -> Option<usize>

§

fn set_max(&mut self, max: Option<usize>) -> Option<usize>

§

fn set_name(&mut self, name: String)

§

fn name(&self) -> Option<String>

§

fn id(&self) -> [u8; 4]

§

fn message(&self, level: MessageLevel, message: String)

§

fn info(&self, message: String)

§

fn done(&self, message: String)

§

fn fail(&self, message: String)

§

fn show_throughput(&self, start: Instant)

§

fn show_throughput_with( &self, start: Instant, step: usize, unit: Unit, level: MessageLevel )

Implementors§

§

impl Progress for BoxedDynNestedProgress

§

impl Progress for Discard

§

impl<L, R> Progress for Either<L, R>where L: Progress, R: Progress,

§

impl<T> Progress for DoOrDiscard<T>where T: Progress,

§

impl<T> Progress for DynNestedProgressToNestedProgress<T>where T: Progress + ?Sized,

§

impl<T> Progress for ThroughputOnDrop<T>where T: NestedProgress,