pub trait IndicatifSpanExt {
// Required methods
fn pb_set_style(&self, style: &ProgressStyle);
fn pb_start(&self);
fn pb_set_length(&self, len: u64);
fn pb_set_position(&self, pos: u64);
fn pb_inc(&self, delta: u64);
fn pb_inc_length(&self, delta: u64);
fn pb_set_message(&self, msg: &str);
fn pb_tick(&self);
}
Expand description
Utilities to modify the progress bar associated to tracing Span
’s (if one exists).
For example, you can call these on the current Span:
use tracing_indicatif::span_ext::IndicatifSpanExt;
use indicatif::ProgressStyle;
tracing::Span::current().pb_set_style(&ProgressStyle::default_spinner());
NOTE: These methods will silently have no effect if a
IndicatifLayer
was not registered with the tracing subscriber,
or if this span was filtered for the registered IndicatifLayer
. Because of this behavior, you
can “safely” call these methods inside of non-CLI contexts as these methods will gracefully
do nothing if you have not enabled progress bars for your tracing spans.
Required Methods§
Sourcefn pb_set_style(&self, style: &ProgressStyle)
fn pb_set_style(&self, style: &ProgressStyle)
Sets the ProgressStyle
of the progress bar associated with this span.
If this span has not yet been entered, this will be the progress style the progress bar for this span uses when the span is entered for the first time. If this span has been entered, this will update the existing progress bar’s style.
Sourcefn pb_start(&self)
fn pb_start(&self)
Briefly enters the span, which starts the progress bar for the span.
Has no effect if the span has already been entered before.
Sourcefn pb_set_length(&self, len: u64)
fn pb_set_length(&self, len: u64)
Sets the length of the progress bar for this span. See
set_length
.
Sourcefn pb_set_position(&self, pos: u64)
fn pb_set_position(&self, pos: u64)
Sets the position of the progress bar for this span. See
set_position
.
WARNING: you should call Self::pb_set_length
at least once before calling this method, or you
may see a buggy progress bar.
Sourcefn pb_inc(&self, delta: u64)
fn pb_inc(&self, delta: u64)
Increments the position of the progress bar for this span. See
inc
.
WARNING: you should call Self::pb_set_length
at least once before calling this method, or you
may see a buggy progress bar.
Sourcefn pb_inc_length(&self, delta: u64)
fn pb_inc_length(&self, delta: u64)
Increments the length of the progress bar for this span. See
inc_length
.
Has no effect if Self::pb_set_length
has not been called at least once.
Sourcefn pb_set_message(&self, msg: &str)
fn pb_set_message(&self, msg: &str)
Sets the message of the progress bar for this span. See
set_message
.