pub trait DisplayValue {
// Required methods
fn dyn_hash(&self, state: &mut dyn Hasher);
fn display_unit(&self, w: &mut dyn Write, value: usize) -> Result<(), Error>;
// Provided methods
fn display_current_value(
&self,
w: &mut dyn Write,
value: usize,
_upper: Option<usize>,
) -> Result<(), Error> { ... }
fn separator(
&self,
w: &mut dyn Write,
_value: usize,
_upper: Option<usize>,
) -> Result<(), Error> { ... }
fn display_upper_bound(
&self,
w: &mut dyn Write,
upper_bound: usize,
_value: usize,
) -> Result<(), Error> { ... }
fn display_percentage(
&self,
w: &mut dyn Write,
percentage: f64,
) -> Result<(), Error> { ... }
fn display_throughput(
&self,
w: &mut dyn Write,
throughput: &Throughput,
) -> Result<(), Error> { ... }
fn fraction_and_time_unit(
&self,
timespan: Duration,
) -> (Option<f64>, &'static str) { ... }
}
Available on crate feature
progress
only.Expand description
A trait to encapsulate all capabilities needed to display a value with unit within a renderer.
Required Methods§
Provided Methods§
sourcefn display_current_value(
&self,
w: &mut dyn Write,
value: usize,
_upper: Option<usize>,
) -> Result<(), Error>
fn display_current_value( &self, w: &mut dyn Write, value: usize, _upper: Option<usize>, ) -> Result<(), Error>
Display the absolute value
representing the current progress of an operation and write it to w
.
The upper
bound is possibly provided when known to add context, even though it is not to be output
as part of this method call.
sourcefn separator(
&self,
w: &mut dyn Write,
_value: usize,
_upper: Option<usize>,
) -> Result<(), Error>
fn separator( &self, w: &mut dyn Write, _value: usize, _upper: Option<usize>, ) -> Result<(), Error>
Emit a token to separate two values.
The value
and its upper
bound are provided to add context, even though it is not to be output
as part of this method call.
sourcefn display_upper_bound(
&self,
w: &mut dyn Write,
upper_bound: usize,
_value: usize,
) -> Result<(), Error>
fn display_upper_bound( &self, w: &mut dyn Write, upper_bound: usize, _value: usize, ) -> Result<(), Error>
Emit the upper_bound
to w
.
The value
is provided to add context, even though it is not to be output as part of this method call.
sourcefn display_percentage(
&self,
w: &mut dyn Write,
percentage: f64,
) -> Result<(), Error>
fn display_percentage( &self, w: &mut dyn Write, percentage: f64, ) -> Result<(), Error>
Emit percentage
to w
.
sourcefn display_throughput(
&self,
w: &mut dyn Write,
throughput: &Throughput,
) -> Result<(), Error>
fn display_throughput( &self, w: &mut dyn Write, throughput: &Throughput, ) -> Result<(), Error>
Emit the throughput
of an operation to w
.