pub struct Item { /* private fields */ }
Available on crate feature progress-tree only.
Expand description

A Tree represents an element of the progress tree.

It can be used to set progress and send messages.

let tree = prodash::tree::Root::new();
let mut progress = tree.add_child("task 1");

progress.init(Some(10), Some("elements".into()));
for p in 0..10 {
    progress.set(p);
}
progress.done("great success");
let mut  sub_progress = progress.add_child_with_id("sub-task 1", *b"TSK2");
sub_progress.init(None, None);
sub_progress.set(5);
sub_progress.fail("couldn't finish");

Implementations§

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.

If unit is Some(…), it is used for display purposes only. It should be using the plural.

If this method is never called, this Item will serve as organizational unit, useful to add more structure to the progress tree.

Note that this method can be called multiple times, changing the bounded-ness and unit at will.

Set the name of this task’s progress to the given name.

Get the name of this task’s progress

Get the stable identifier of this instance.

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

Returns the maximum about of items we expect, as provided with the init(…) call

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

Returns the (cloned) unit associated with this Progress

Set the current progress to the given step.

Note: that this call has no effect unless init(…) was called before.

Increment the current progress by the given step.

Note: that this call has no effect unless init(…) was called before.

Increment the current progress by one.

Note: that this call has no effect unless init(…) was called before.

Call to indicate that progress cannot be indicated, and that the task cannot be interrupted. Use this, as opposed to halted(…), if a non-interruptable call is about to be made without support for any progress indication.

If eta is Some(…), it specifies the time at which this task is expected to make progress again.

The halted-state is undone next time tree::Item::running(…) is called.

Call to indicate that progress cannot be indicated, even though the task can be interrupted. Use this, as opposed to blocked(…), if an interruptable call is about to be made without support for any progress indication.

If eta is Some(…), it specifies the time at which this task is expected to make progress again.

The halted-state is undone next time tree::Item::running(…) is called.

Call to indicate that progress is back in running state, which should be called after the reason for calling blocked() or halted() has passed.

Adds a new child Tree, whose parent is this instance, with the given name.

Important: The depth of the hierarchy is limited to tree::Key::max_level. Exceeding the level will be ignored, and new tasks will be added to this instance’s level instead.

Adds a new child Tree, whose parent is this instance, with the given name and id.

Important: The depth of the hierarchy is limited to tree::Key::max_level. Exceeding the level will be ignored, and new tasks will be added to this instance’s level instead.

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.

Create a message indicating the task is done

Create a message indicating the task failed

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

Trait Implementations§

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
The type of progress returned by add_child().
Adds a new child, whose parent is this instance, with the given name. Read more
Adds a new child, whose parent is this instance, with the given name and id. Read more
Initialize the Item for receiving progress information. Read more
Set the current progress to the given step. The cost of this call is negligible, making manual throttling not necessary. Read more
Returns the (cloned) unit associated with this Progress
Returns the maximum about of items we expect, as provided with the init(…) call
Set the maximum value to max and return the old maximum value.
Returns the current step, as controlled by inc*(…) calls
Increment the current progress to the given step. The cost of this call is negligible, making manual throttling not necessary.
Set the name of the instance, altering the value given when crating it with add_child(…) The progress is allowed to discard it.
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’.
Get a stable identifier for the progress instance. Note that it could be unknown.
Create a message of the given level and store it with the progress tree. Read more
If available, return an atomic counter for direct access to the underlying state. Read more
Increment the current progress to the given 1. The cost of this call is negligible, making manual throttling not necessary.
Create a message providing additional information about the progress thus far.
Create a message indicating the task is done successfully
Create a message indicating the task failed
A shorthand to print throughput information
A shorthand to print throughput information, with the given step and unit, and message level.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.