Skip to main content

TimeUnit

Enum TimeUnit 

Source
pub enum TimeUnit {
    NanoSeconds,
    MicroSeconds,
    MilliSeconds,
    Seconds,
    Minutes,
    Hours,
    Days,
}
Expand description

A unit of time, from nanoseconds to days.

Time units are used to display timings and speeds. Usually the most convenient unit is chosen automatically, but you can fix a specific unit with ProgressLog::time_unit.

Variants§

§

NanoSeconds

A nanosecond (10⁻⁹ seconds).

§

MicroSeconds

A microsecond (10⁻⁶ seconds).

§

MilliSeconds

A millisecond (10⁻³ seconds).

§

Seconds

A second.

§

Minutes

A minute (60 seconds).

§

Hours

An hour (3600 seconds).

§

Days

A day (86400 seconds).

Implementations§

Source§

impl TimeUnit

Source

pub const VALUES: [TimeUnit; 7]

All time units, in increasing order of duration.

Source

pub const fn label(&self) -> &'static str

Returns the label used to display this time unit (e.g., s for Seconds).

Source

pub const fn as_seconds(&self) -> f64

Returns the length of this time unit in seconds.

Source

pub const fn nice_time_unit(seconds: f64) -> Self

Returns the largest time unit not exceeding the given duration in seconds; it is used to display per-item timings.

For durations shorter than a nanosecond, NanoSeconds is returned.

Source

pub const fn nice_speed_unit(seconds: f64) -> Self

Returns the smallest time unit, starting from Seconds, in which an activity taking the given number of seconds per item progresses at a speed of at least one item per unit; it is used to display speeds.

For activities slower than one item per day, Days is returned.

Source

pub fn pretty_print(milliseconds: u128) -> String

Pretty-prints a duration expressed in milliseconds.

Durations of less than a second are displayed as {}ms; longer durations are displayed as days, hours, minutes, and seconds (e.g., 1d 3h 10m 5s), discarding the sub-second part.

Trait Implementations§

Source§

impl Clone for TimeUnit

Source§

fn clone(&self) -> TimeUnit

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TimeUnit

Source§

impl Debug for TimeUnit

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.