Struct prodash::unit::human::Human

source ·
pub struct Human {
    pub name: &'static str,
    pub formatter: Formatter,
}
Expand description

A helper for formatting numbers in a format easily read by humans in renderers, as in 2.54 million objects

Fields§

§name: &'static str

The name of the represented unit, like ‘items’ or ‘objects’.

§formatter: Formatter

The formatter to format the actual numbers.

Implementations§

source§

impl Human

source

pub fn new(formatter: Formatter, name: &'static str) -> Self

A convenience method to create a new new instance and its formatter and name fields.

Trait Implementations§

source§

impl Debug for Human

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DisplayValue for Human

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. Read more
source§

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

Emit the upper_bound to w. Read more
source§

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

A way to hash our state without using generics. Read more
source§

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

Emit the unit of value to w. Read more
source§

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

Emit a token to separate two values. Read more
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).

Auto Trait Implementations§

§

impl RefUnwindSafe for Human

§

impl Send for Human

§

impl Sync for Human

§

impl Unpin for Human

§

impl UnwindSafe for Human

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more