pub trait DisplayValue {
    // Required methods
    fn dyn_hash(&self, state: &mut dyn Hasher);
    fn display_unit(&self, w: &mut dyn Write, value: Step) -> Result;

    // Provided methods
    fn display_current_value(
        &self,
        w: &mut dyn Write,
        value: Step,
        _upper: Option<Step>
    ) -> Result { ... }
    fn separator(
        &self,
        w: &mut dyn Write,
        _value: Step,
        _upper: Option<Step>
    ) -> Result { ... }
    fn display_upper_bound(
        &self,
        w: &mut dyn Write,
        upper_bound: Step,
        _value: Step
    ) -> Result { ... }
    fn display_percentage(&self, w: &mut dyn Write, percentage: f64) -> Result { ... }
    fn display_throughput(
        &self,
        w: &mut dyn Write,
        throughput: &Throughput
    ) -> Result { ... }
    fn fraction_and_time_unit(
        &self,
        timespan: Duration
    ) -> (Option<f64>, &'static str) { ... }
}
Expand description

A trait to encapsulate all capabilities needed to display a value with unit within a renderer.

Required Methods§

source

fn dyn_hash(&self, state: &mut dyn Hasher)

A way to hash our state without using generics.

This helps to determine quickly if something changed.

source

fn display_unit(&self, w: &mut dyn Write, value: Step) -> Result

Emit the unit of value to w.

The value is provided to add context, even though it is not to be output as part of this method call.

Provided Methods§

source

fn display_current_value( &self, w: &mut dyn Write, value: Step, _upper: Option<Step> ) -> Result

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.

source

fn separator( &self, w: &mut dyn Write, _value: Step, _upper: Option<Step> ) -> Result

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.

source

fn display_upper_bound( &self, w: &mut dyn Write, upper_bound: Step, _value: Step ) -> Result

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.

source

fn display_percentage(&self, w: &mut dyn Write, percentage: f64) -> Result

Emit percentage to w.

source

fn display_throughput( &self, w: &mut dyn Write, throughput: &Throughput ) -> Result

Emit the throughput of an operation to w.

source

fn fraction_and_time_unit( &self, timespan: Duration ) -> (Option<f64>, &'static str)

Given a timespan, return a fraction of the timespan based on the given unit, i.e. (possible fraction, unit).

Implementations on Foreign Types§

source§

impl DisplayValue for &'static str

source§

fn dyn_hash(&self, state: &mut dyn Hasher)

source§

fn display_unit(&self, w: &mut dyn Write, _value: usize) -> Result

Implementors§